Changed DatabaseConnection
This commit is contained in:
@@ -1 +1 @@
|
||||
|
||||
# imports:
|
||||
|
@@ -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
|
||||
|
@@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user