mirror of
https://github.com/reconurge/flowsint.git
synced 2026-07-24 05:34:25 -05:00
21 lines
501 B
Python
21 lines
501 B
Python
from sqlalchemy import create_engine
|
|
from sqlalchemy.orm import sessionmaker, declarative_base, Session
|
|
import os
|
|
from dotenv import load_dotenv
|
|
# Remplace avec ton URL de BDD
|
|
DATABASE_URL = os.getenv("DATABASE_URL")
|
|
|
|
load_dotenv()
|
|
|
|
engine = create_engine(DATABASE_URL, pool_pre_ping=True)
|
|
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
|
|
|
Base = declarative_base()
|
|
|
|
|
|
def get_db() -> Session:
|
|
db = SessionLocal()
|
|
try:
|
|
yield db
|
|
finally:
|
|
db.close() |