
- Created customer, driver, and order models with SQLAlchemy - Implemented CRUD API endpoints for all entities - Set up SQLite database with Alembic migrations - Added health check and base URL endpoints - Configured CORS middleware for all origins - Updated README with comprehensive documentation
23 lines
543 B
Python
23 lines
543 B
Python
from pathlib import Path
|
|
from sqlalchemy import create_engine
|
|
from sqlalchemy.orm import sessionmaker
|
|
from .base import Base
|
|
|
|
DB_DIR = Path("/app") / "storage" / "db"
|
|
DB_DIR.mkdir(parents=True, exist_ok=True)
|
|
|
|
SQLALCHEMY_DATABASE_URL = f"sqlite:///{DB_DIR}/db.sqlite"
|
|
|
|
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() |