2021.4 #19
@ -26,9 +26,6 @@ class DatabaseContext(DatabaseContextABC):
|
|||||||
def session(self) -> Session:
|
def session(self) -> Session:
|
||||||
return self._db.session
|
return self._db.session
|
||||||
|
|
||||||
def create(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def connect(self, connection_string: str):
|
def connect(self, connection_string: str):
|
||||||
self._db.connect(connection_string)
|
self._db.connect(connection_string)
|
||||||
self._create_tables()
|
self._create_tables()
|
||||||
|
@ -15,7 +15,18 @@ class DatabaseContextABC(ABC):
|
|||||||
def session(self) -> Session: pass
|
def session(self) -> Session: pass
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
@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