15 lines
346 B
Python
15 lines
346 B
Python
from sqlalchemy import create_engine
|
|
from sqlalchemy.orm import sessionmaker, scoped_session
|
|
from app.config import Config
|
|
|
|
engine = create_engine(Config.DATABASE_URL, pool_pre_ping=True)
|
|
Session = scoped_session(sessionmaker(bind=engine))
|
|
|
|
|
|
def get_db_session():
|
|
return Session()
|
|
|
|
|
|
def close_db_session(exception=None):
|
|
Session.remove()
|