Add debug logs when retrying database connection or testing the write permissions

This commit is contained in:
Théophile Diot 2024-05-25 18:43:53 +01:00
parent 58025b5ff4
commit 9160bf8ce9
No known key found for this signature in database
GPG key ID: 248FEA4BAE400D06

View file

@ -217,6 +217,7 @@ class Database:
def test_write(self):
"""Test the write access to the database"""
self.logger.debug("Testing write access to the database ...")
with self.__db_session() as session:
table_name = uuid4().hex
session.execute(text(f"CREATE TABLE IF NOT EXISTS test_{table_name} (id INT)"))
@ -226,6 +227,8 @@ class Database:
def retry_connection(self, *, readonly: bool = False, fallback: bool = False, **kwargs) -> None:
"""Retry the connection to the database"""
self.logger.debug(f"Retrying the connection to the database {'in read-only mode' if readonly else ''}{' with fallback' if fallback else ''} ...")
assert self.sql_engine is not None
if fallback and not self.database_uri_readonly: