Feature: Add app name to each db connection (#1393)
Co-authored-by: Adrià Casajús <adria.casajus@proton.ch>
This commit is contained in:
parent
36d1626972
commit
3bc976c322
|
@ -160,6 +160,7 @@ if "DKIM_PRIVATE_KEY_PATH" in os.environ:
|
|||
|
||||
# Database
|
||||
DB_URI = os.environ["DB_URI"]
|
||||
DB_CONN_NAME = os.environ.get("DB_CONN_NAME", "webapp")
|
||||
|
||||
# Flask secret
|
||||
FLASK_SECRET = os.environ["FLASK_SECRET"]
|
||||
|
|
|
@ -3,9 +3,12 @@ from sqlalchemy import create_engine
|
|||
from sqlalchemy.orm import scoped_session
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
from app.config import DB_URI
|
||||
from app import config
|
||||
|
||||
engine = create_engine(DB_URI)
|
||||
|
||||
engine = create_engine(
|
||||
config.DB_URI, connect_args={"application_name": config.DB_CONN_NAME}
|
||||
)
|
||||
connection = engine.connect()
|
||||
|
||||
Session = scoped_session(sessionmaker(bind=connection))
|
||||
|
|
Loading…
Reference in New Issue