mirror of
https://github.com/creyD/creyPY.git
synced 2026-04-13 03:40:31 +02:00
16 lines
451 B
Python
16 lines
451 B
Python
from typing import Generator
|
|
|
|
from sqlalchemy import create_engine
|
|
from sqlalchemy.orm import sessionmaker
|
|
from sqlalchemy.orm.session import Session
|
|
|
|
from .common import SQLALCHEMY_DATABASE_URL, name
|
|
|
|
engine = create_engine(SQLALCHEMY_DATABASE_URL + name, pool_pre_ping=True)
|
|
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
|
|
|
|
|
def get_db() -> Generator[Session, None, None]:
|
|
with SessionLocal() as db:
|
|
yield db
|