16 lines
259 B
Python
16 lines
259 B
Python
from sqlalchemy.orm import sessionmaker
|
|
from .connection import engine
|
|
|
|
SessionLocal = sessionmaker(
|
|
autocommit=False,
|
|
autoflush=False,
|
|
bind=engine
|
|
)
|
|
|
|
def get_db():
|
|
db = SessionLocal()
|
|
try:
|
|
yield db
|
|
finally:
|
|
db.close()
|