Improved database context

This commit is contained in:
Sven Heidemann 2021-03-30 10:06:07 +02:00
parent 260fe06be8
commit 0cdecd893a
2 changed files with 9 additions and 0 deletions

View File

@ -30,6 +30,9 @@ class DatabaseContext(DatabaseContextABC):
self._db.connect(connection_string) self._db.connect(connection_string)
self._create_tables() self._create_tables()
def save_changes(self):
self._db.session.commit()
def _create_tables(self): def _create_tables(self):
try: try:
for subclass in DatabaseModel.__subclasses__(): for subclass in DatabaseModel.__subclasses__():

View File

@ -27,6 +27,12 @@ class DatabaseContextABC(ABC):
""" """
pass pass
def save_changes(self):
"""
Saves changes of the database
"""
pass
@abstractmethod @abstractmethod
def _create_tables(self): def _create_tables(self):
""" """