Improved session reference
This commit is contained in:
parent
03ba1d1847
commit
9662584560
@ -1,7 +1,7 @@
|
||||
from abc import abstractmethod, ABC
|
||||
|
||||
from sqlalchemy import engine
|
||||
from sqlalchemy.orm import session
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
|
||||
class DatabaseConnectionBase(ABC):
|
||||
@ -15,7 +15,7 @@ class DatabaseConnectionBase(ABC):
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def session(self) -> session: pass
|
||||
def session(self) -> Session: pass
|
||||
|
||||
@abstractmethod
|
||||
def connect(self, connection_string: str): pass
|
||||
|
@ -1,7 +1,7 @@
|
||||
from typing import Optional
|
||||
|
||||
from sqlalchemy import engine, create_engine
|
||||
from sqlalchemy.orm import session, sessionmaker
|
||||
from sqlalchemy.orm import Session, sessionmaker
|
||||
|
||||
from sh_edraft.database.connection.base.database_connection_base import DatabaseConnectionBase
|
||||
from sh_edraft.database.model.database_settings import DatabaseSettings
|
||||
@ -16,7 +16,7 @@ class DatabaseConnection(DatabaseConnectionBase):
|
||||
self._db_settings = database_settings
|
||||
|
||||
self._engine: Optional[engine] = None
|
||||
self._session: Optional[session] = None
|
||||
self._session: Optional[Session] = None
|
||||
self._credentials: Optional[str] = None
|
||||
|
||||
@property
|
||||
@ -24,7 +24,7 @@ class DatabaseConnection(DatabaseConnectionBase):
|
||||
return self._engine
|
||||
|
||||
@property
|
||||
def session(self) -> session:
|
||||
def session(self) -> Session:
|
||||
return self._session
|
||||
|
||||
def connect(self, connection_string: str):
|
||||
|
@ -1,7 +1,7 @@
|
||||
from abc import abstractmethod
|
||||
|
||||
from sqlalchemy import engine
|
||||
from sqlalchemy.orm import session
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from sh_edraft.service.base.service_base import ServiceBase
|
||||
|
||||
@ -18,7 +18,7 @@ class DatabaseContextBase(ServiceBase):
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def session(self) -> session: pass
|
||||
def session(self) -> Session: pass
|
||||
|
||||
@abstractmethod
|
||||
def connect(self, connection_string: str): pass
|
||||
|
@ -1,5 +1,5 @@
|
||||
from sqlalchemy import engine, Table
|
||||
from sqlalchemy.orm import session
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from sh_edraft.database.connection.database_connection import DatabaseConnection
|
||||
from sh_edraft.database.connection.base.database_connection_base import DatabaseConnectionBase
|
||||
@ -22,7 +22,7 @@ class DatabaseContext(DatabaseContextBase):
|
||||
return self._db.engine
|
||||
|
||||
@property
|
||||
def session(self) -> session:
|
||||
def session(self) -> Session:
|
||||
return self._db.session
|
||||
|
||||
def create(self):
|
||||
|
Loading…
Reference in New Issue
Block a user