diff --git a/PyFunceble/database/session.py b/PyFunceble/database/session.py index b8fc078a..caa27f4b 100644 --- a/PyFunceble/database/session.py +++ b/PyFunceble/database/session.py @@ -142,7 +142,9 @@ def init_db_sessions(self) -> "DBSession": if PyFunceble.sessions.DB_ENGINE is None: PyFunceble.sessions.DB_ENGINE = sqlalchemy.create_engine( - self.credential.get_uri(), poolclass=sqlalchemy.pool.NullPool + self.credential.get_uri(), + poolclass=sqlalchemy.pool.NullPool, + pool_pre_ping=True, ) PyFunceble.sessions.DB_FACTORY = sqlalchemy.orm.sessionmaker( @@ -150,7 +152,6 @@ def init_db_sessions(self) -> "DBSession": autoflush=True, autocommit=False, expire_on_commit=False, - pre_ping=True, ) return self @@ -177,7 +178,9 @@ def get_new_session(self) -> sqlalchemy.orm.sessionmaker: """ engine = sqlalchemy.create_engine( - self.credential.get_uri(), poolclass=sqlalchemy.pool.NullPool + self.credential.get_uri(), + poolclass=sqlalchemy.pool.NullPool, + pool_pre_ping=True, ) return sqlalchemy.orm.sessionmaker( @@ -185,7 +188,6 @@ def get_new_session(self) -> sqlalchemy.orm.sessionmaker: autoflush=True, autocommit=False, expire_on_commit=False, - pre_ping=True, ) @execute_if_authorized(None) @@ -195,16 +197,13 @@ def get_new_pool_session(self) -> sqlalchemy.orm.sessionmaker: Create and return a new session. """ - engine = sqlalchemy.create_engine( - self.credential.get_uri(), - ) + engine = sqlalchemy.create_engine(self.credential.get_uri(), pool_pre_ping=True) return sqlalchemy.orm.sessionmaker( bind=engine, autoflush=True, autocommit=False, expire_on_commit=False, - pre_ping=True, ) def close(self) -> "DBSession":