refactor: integrate Alembic, restructure project, and clean up
- 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
This commit is contained in:
27
backend/app/db/session.py
Normal file
27
backend/app/db/session.py
Normal file
@@ -0,0 +1,27 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user