chore(quality): apply ruff autofixes and formatting (8 fixes, 18 files reformatted)
This commit is contained in:
+18
-8
@@ -1,20 +1,30 @@
|
||||
"""Database connection and session management."""
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from app.config import settings
|
||||
from sqlalchemy.orm import sessionmaker, DeclarativeBase
|
||||
from typing import Generator
|
||||
|
||||
from app.config import get_settings
|
||||
|
||||
settings = get_settings()
|
||||
|
||||
# Create engine
|
||||
engine = create_engine(
|
||||
settings.DATABASE_URL,
|
||||
connect_args={"check_same_thread": False} if "sqlite" in settings.DATABASE_URL else {}
|
||||
connect_args={"check_same_thread": False}
|
||||
if "sqlite" in settings.DATABASE_URL
|
||||
else {},
|
||||
echo=settings.DEBUG,
|
||||
)
|
||||
|
||||
# Session factory
|
||||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
def get_db():
|
||||
"""Get database session."""
|
||||
class Base(DeclarativeBase):
|
||||
pass
|
||||
|
||||
|
||||
def get_db() -> Generator:
|
||||
"""Dependency for FastAPI to get database session."""
|
||||
db = SessionLocal()
|
||||
try:
|
||||
yield db
|
||||
|
||||
Reference in New Issue
Block a user