2021.4 #19
@ -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__():
|
||||||
|
@ -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):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user