CoolFace
Apppublic

BytecodeApps/docverse-api

sourceHugging Faceapache-2.0updated 7mo agoView on Hugging Face
0likes
database.py20 linesDownload Raw Back to db
1import os2from sqlalchemy import create_engine3from sqlalchemy.orm import sessionmaker4 5# Fetch from environment or use a default fallback for local dev6DATABASE_URL = os.getenv("DATABASE_URL", "postgresql://postgres:[docverse12345!]@db.lhqwwclldcvjoqmidznc.supabase.co:5432/postgres")7 8# Create SQLAlchemy engine mapping to PostgreSQL9engine = create_engine(DATABASE_URL, echo=False)10 11# SessionLocal class will be a factory for new Session objects12SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)13 14def get_db():15    db = SessionLocal()16    try:17        yield db18    finally:19        db.close()20