feat: add new file

This commit is contained in:
Daniel
2026-03-24 10:35:58 +08:00
commit 2788fc468f
9058 changed files with 896924 additions and 0 deletions

21
backend/app/database.py Normal file
View File

@@ -0,0 +1,21 @@
import os
from sqlalchemy import create_engine
from sqlalchemy.orm import declarative_base, sessionmaker
DATABASE_URL = os.getenv(
"DATABASE_URL", "postgresql+psycopg://exam_user:exam_pass@localhost:5432/exam_helper"
)
engine = create_engine(DATABASE_URL, future=True, pool_pre_ping=True)
SessionLocal = sessionmaker(bind=engine, autoflush=False, autocommit=False, future=True)
Base = declarative_base()
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()