From 1d4a6c3e3b84cd6461171b1bdf85a7203612ef87 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 30 Nov 2021 15:18:07 +0100 Subject: [PATCH] Improved db context logging --- src/gismo_data/db_context.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gismo_data/db_context.py b/src/gismo_data/db_context.py index b40a8f1..77ea0b1 100644 --- a/src/gismo_data/db_context.py +++ b/src/gismo_data/db_context.py @@ -15,7 +15,13 @@ class DBContext(DatabaseContext): def connect(self, database_settings: DatabaseSettings): try: self._logger.debug(__name__, "Connecting to database") - super(DBContext, self).connect(database_settings) + self._db.connect(database_settings) + for table in self._tables: + self._logger.debug(__name__, f"Create table if not exists: {table}") + self._logger.trace(__name__, f'Send SQL command: {table.get_create_string()}') + self._db.cursor.execute(table.get_create_string()) + + self.save_changes() self._logger.info(__name__, "Connected to database") except Exception as e: self._logger.fatal(__name__, "Connecting to database failed", e)