2021.4 #19
@ -26,9 +26,6 @@ class DatabaseContext(DatabaseContextABC):
|
||||
def session(self) -> Session:
|
||||
return self._db.session
|
||||
|
||||
def create(self):
|
||||
pass
|
||||
|
||||
def connect(self, connection_string: str):
|
||||
self._db.connect(connection_string)
|
||||
self._create_tables()
|
||||
|
@ -15,7 +15,18 @@ class DatabaseContextABC(ABC):
|
||||
def session(self) -> Session: pass
|
||||
|
||||
@abstractmethod
|
||||
def connect(self, connection_string: str): pass
|
||||
def connect(self, connection_string: str):
|
||||
"""
|
||||
Connects to a database with connection string
|
||||
:param connection_string:
|
||||
:return:
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def _create_tables(self): pass
|
||||
def _create_tables(self):
|
||||
"""
|
||||
Create all tables for application from database model
|
||||
:return:
|
||||
"""
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user