Refactored code
This commit is contained in:
26
src_old/sh_edraft/database/context/base/__init__.py
Normal file
26
src_old/sh_edraft/database/context/base/__init__.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
sh_edraft.database.context.base
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
:copyright: (c) 2020 sh-edraft.de
|
||||
:license: MIT, see LICENSE for more details.
|
||||
|
||||
"""
|
||||
|
||||
__title__ = 'sh_edraft.database.context.base'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
|
||||
__version__ = '2020.12.9'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
from .database_context_base import DatabaseContextBase
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major=2020, minor=12, micro=9)
|
@@ -0,0 +1,27 @@
|
||||
from abc import abstractmethod
|
||||
|
||||
from sqlalchemy import engine
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from sh_edraft.service.base.service_base import ServiceBase
|
||||
|
||||
|
||||
class DatabaseContextBase(ServiceBase):
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self):
|
||||
ServiceBase.__init__(self)
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def engine(self) -> engine: pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def session(self) -> Session: pass
|
||||
|
||||
@abstractmethod
|
||||
def connect(self, connection_string: str): pass
|
||||
|
||||
@abstractmethod
|
||||
def _create_tables(self): pass
|
Reference in New Issue
Block a user