Files
aitbc/apps/coordinator-api/src/app/database.py
aitbc1 9302661dc4 fix: improve blockchain node RPC responses and database path consistency
- Add transaction data to RPC responses (get_block, get_blocks_range)
- Fix import_block to handle transactions parameter
- Change database paths to absolute paths for consistency
- Make dev_heartbeat.py executable
2026-03-24 10:12:24 +01:00

23 lines
730 B
Python
Executable File

"""Database configuration for the coordinator API."""
from sqlmodel import create_engine, SQLModel
from sqlalchemy import StaticPool
from .config import settings
# Create database engine using URL from config
engine = create_engine(
settings.database_url,
connect_args={"check_same_thread": False} if settings.database_url.startswith("sqlite") else {},
poolclass=StaticPool if settings.database_url.startswith("sqlite") else None,
echo=settings.test_mode # Enable SQL logging for debugging in test mode
)
def create_db_and_tables():
"""Create database and tables"""
SQLModel.metadata.create_all(engine)
async def init_db():
"""Initialize database by creating tables"""
create_db_and_tables()