
- Moved DB_DIR Path definition outside Settings class to fix Pydantic 2.x annotation error - Updated path to use project-specific path rather than /app - Added start.py script to validate app loading generated with BackendIM... (backend.im)
19 lines
438 B
Python
19 lines
438 B
Python
from sqlalchemy import create_engine
|
|
from sqlalchemy.orm import sessionmaker
|
|
from app.core.config import settings
|
|
|
|
SQLALCHEMY_DATABASE_URL = settings.DATABASE_URL
|
|
|
|
engine = create_engine(
|
|
SQLALCHEMY_DATABASE_URL,
|
|
connect_args={"check_same_thread": False}
|
|
)
|
|
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
|
|
|
|
|
def get_db():
|
|
db = SessionLocal()
|
|
try:
|
|
yield db
|
|
finally:
|
|
db.close() |