Michael Manganiello a85c84a7d4
misc: Use single SQLAlchemy engine and session maker
As recommended by SQLAlchemy [1], this change makes a single
instantiation of the database engine and session maker, instead of one
entity per handler.

It also uses the provided `URL` constructor to better define the
database URL structure.

[1] https://docs.sqlalchemy.org/en/20/core/connections.html#basic-usage
2024-08-21 09:56:28 -03:00

10 lines
302 B
Python

from config.config_manager import ConfigManager
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
sync_engine = create_engine(ConfigManager.get_db_engine(), pool_pre_ping=True)
sync_session = sessionmaker(bind=sync_engine, expire_on_commit=False)
class DBBaseHandler: ...