Added docs for cpl.database

This commit is contained in:
2021-05-17 17:05:43 +02:00
parent 7b90b5af57
commit e562c31033
11 changed files with 51 additions and 32 deletions

View File

@@ -19,9 +19,11 @@ class DatabaseConnectionABC(ABC):
@abstractmethod
def connect(self, connection_string: str):
"""
Connects to a database by connection string
:param connection_string:
:return:
r"""Connects to a database by connection string
Parameter
---------
connection_string: :class:`str`
Database connection string, see: https://docs.sqlalchemy.org/en/14/core/engines.html
"""
pass

View File

@@ -20,23 +20,20 @@ class DatabaseContextABC(ABC):
@abstractmethod
def connect(self, connection_string: str):
"""
Connects to a database with connection string
:param connection_string:
:return:
r"""Connects to a database by connection string
Parameter
---------
connection_string: :class:`str`
Database connection string, see: https://docs.sqlalchemy.org/en/14/core/engines.html
"""
pass
def save_changes(self):
"""
Saves changes of the database
"""
r"""Saves changes of the database"""
pass
@abstractmethod
def _create_tables(self):
"""
Create all tables for application from database model
:return:
"""
r"""Create all tables for application from database model"""
pass

View File

@@ -68,6 +68,12 @@ class DatabaseSettings(ConfigurationModelABC):
self._echo = echo
def from_dict(self, settings: dict):
r"""Sets attributes from given dict
Parameter
---------
settings: :class:`dict`
"""
try:
self._connection_string = settings[DatabaseSettingsNameEnum.connection_string.value]
self._credentials = settings[DatabaseSettingsNameEnum.credentials.value]