update code structure and get session on each query
All checks were successful
Build Docker Image / build (push) Successful in 12m54s
All checks were successful
Build Docker Image / build (push) Successful in 12m54s
This commit is contained in:
14
app/database.py
Normal file
14
app/database.py
Normal file
@@ -0,0 +1,14 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user