A-0.2 - Datenbankverbindung #35
@ -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)
|
||||
|
Reference in New Issue
Block a user