A-0.2 - Datenbankverbindung #35

Merged
edraft merged 13 commits from 0.2 into Alpha 2021-12-01 17:57:52 +01:00
Showing only changes of commit 1d4a6c3e3b - Show all commits

View File

@ -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)