mirror of
https://github.com/simple-login/app.git
synced 2024-11-18 01:40:38 +01:00
3bc976c322
Co-authored-by: Adrià Casajús <adria.casajus@proton.ch>
18 lines
531 B
Python
18 lines
531 B
Python
import sqlalchemy
|
|
from sqlalchemy import create_engine
|
|
from sqlalchemy.orm import scoped_session
|
|
from sqlalchemy.orm import sessionmaker
|
|
|
|
from app import config
|
|
|
|
|
|
engine = create_engine(
|
|
config.DB_URI, connect_args={"application_name": config.DB_CONN_NAME}
|
|
)
|
|
connection = engine.connect()
|
|
|
|
Session = scoped_session(sessionmaker(bind=connection))
|
|
|
|
# Session is actually a proxy, more info on
|
|
# https://docs.sqlalchemy.org/en/14/orm/contextual.html?highlight=scoped_session#implicit-method-access
|
|
Session: sqlalchemy.orm.Session
|