Changed DatabaseConnection

This commit is contained in:
2020-12-11 19:42:09 +01:00
parent d2dc57bc76
commit ee60be9880
4 changed files with 23 additions and 4 deletions

View File

@@ -1 +1 @@
# imports:

View File

@@ -1,5 +1,8 @@
from abc import abstractmethod
from sqlalchemy import engine
from sqlalchemy.orm import session
from sh_edraft.service.base.service_base import ServiceBase
@@ -9,5 +12,13 @@ class DatabaseConnectionBase(ServiceBase):
def __init__(self):
ServiceBase.__init__(self)
@property
@abstractmethod
def use_mysql(self, connection_string: str): pass
def engine(self) -> engine: pass
@property
@abstractmethod
def session(self) -> session: pass
@abstractmethod
def connect(self, connection_string: str): pass

View File

@@ -21,9 +21,17 @@ class DatabaseConnection(DatabaseConnectionBase):
self.create()
@property
def engine(self) -> engine:
return self._engine
@property
def session(self) -> session:
return self._session
def create(self): pass
def use_mysql(self, connection_string: str):
def connect(self, connection_string: str):
try:
self._engine = create_engine(connection_string)