- Add Alembic configuration (alembic.ini, env.py) for database migrations - Remove legacy wheel.db and unnecessary __pycache__ files - Delete models.py to separate SQLAlchemy and Pydantic concerns - Restructure main.py to use modular API routers (user/admin) - Introduce config backend for centralized settings management
27 lines
505 B
Python
27 lines
505 B
Python
from sqlalchemy import create_engine
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
from sqlalchemy.orm import sessionmaker
|
|
|
|
DATABASE_URL = "sqlite:///./wheel.db"
|
|
|
|
engine = create_engine(
|
|
DATABASE_URL,
|
|
connect_args={"check_same_thread": False}
|
|
)
|
|
|
|
SessionLocal = sessionmaker(
|
|
autocommit=False,
|
|
autoflush=False,
|
|
bind=engine
|
|
)
|
|
|
|
# Database Session
|
|
def get_db():
|
|
db = SessionLocal()
|
|
|
|
try:
|
|
yield db
|
|
finally:
|
|
db.close()
|
|
|
|
Base = declarative_base() |