Added docs for cpl.database

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -192,9 +192,13 @@
<dl class="py method"> <dl class="py method">
<dt id="cpl.database.connection.database_connection.DatabaseConnection.connect"> <dt id="cpl.database.connection.database_connection.DatabaseConnection.connect">
<code class="sig-name descname"><span class="pre">connect</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">connection_string</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#cpl.database.connection.database_connection.DatabaseConnection.connect" title="Permalink to this definition"></a></dt> <code class="sig-name descname"><span class="pre">connect</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">connection_string</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#cpl.database.connection.database_connection.DatabaseConnection.connect" title="Permalink to this definition"></a></dt>
<dd><p>Connects to a database by connection string <dd><p>Connects to a database by connection string</p>
:param connection_string: <blockquote>
:return:</p> <div><dl class="simple">
<dt>connection_string: <code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>Database connection string, see: <a class="reference external" href="https://docs.sqlalchemy.org/en/14/core/engines.html">https://docs.sqlalchemy.org/en/14/core/engines.html</a></p>
</dd>
</dl>
</div></blockquote>
</dd></dl> </dd></dl>
<dl class="py method"> <dl class="py method">
@ -219,9 +223,13 @@
<dl class="py method"> <dl class="py method">
<dt id="cpl.database.connection.database_connection_abc.DatabaseConnectionABC.connect"> <dt id="cpl.database.connection.database_connection_abc.DatabaseConnectionABC.connect">
<em class="property"><span class="pre">abstract</span> </em><code class="sig-name descname"><span class="pre">connect</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">connection_string</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#cpl.database.connection.database_connection_abc.DatabaseConnectionABC.connect" title="Permalink to this definition"></a></dt> <em class="property"><span class="pre">abstract</span> </em><code class="sig-name descname"><span class="pre">connect</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">connection_string</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#cpl.database.connection.database_connection_abc.DatabaseConnectionABC.connect" title="Permalink to this definition"></a></dt>
<dd><p>Connects to a database by connection string <dd><p>Connects to a database by connection string</p>
:param connection_string: <blockquote>
:return:</p> <div><dl class="simple">
<dt>connection_string: <code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>Database connection string, see: <a class="reference external" href="https://docs.sqlalchemy.org/en/14/core/engines.html">https://docs.sqlalchemy.org/en/14/core/engines.html</a></p>
</dd>
</dl>
</div></blockquote>
</dd></dl> </dd></dl>
<dl class="py method"> <dl class="py method">

View File

@ -192,9 +192,13 @@
<dl class="py method"> <dl class="py method">
<dt id="cpl.database.context.database_context.DatabaseContext.connect"> <dt id="cpl.database.context.database_context.DatabaseContext.connect">
<code class="sig-name descname"><span class="pre">connect</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">connection_string</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#cpl.database.context.database_context.DatabaseContext.connect" title="Permalink to this definition"></a></dt> <code class="sig-name descname"><span class="pre">connect</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">connection_string</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#cpl.database.context.database_context.DatabaseContext.connect" title="Permalink to this definition"></a></dt>
<dd><p>Connects to a database with connection string <dd><p>Connects to a database by connection string</p>
:param connection_string: <blockquote>
:return:</p> <div><dl class="simple">
<dt>connection_string: <code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>Database connection string, see: <a class="reference external" href="https://docs.sqlalchemy.org/en/14/core/engines.html">https://docs.sqlalchemy.org/en/14/core/engines.html</a></p>
</dd>
</dl>
</div></blockquote>
</dd></dl> </dd></dl>
<dl class="py method"> <dl class="py method">
@ -225,9 +229,13 @@
<dl class="py method"> <dl class="py method">
<dt id="cpl.database.context.database_context_abc.DatabaseContextABC.connect"> <dt id="cpl.database.context.database_context_abc.DatabaseContextABC.connect">
<em class="property"><span class="pre">abstract</span> </em><code class="sig-name descname"><span class="pre">connect</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">connection_string</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#cpl.database.context.database_context_abc.DatabaseContextABC.connect" title="Permalink to this definition"></a></dt> <em class="property"><span class="pre">abstract</span> </em><code class="sig-name descname"><span class="pre">connect</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">connection_string</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#cpl.database.context.database_context_abc.DatabaseContextABC.connect" title="Permalink to this definition"></a></dt>
<dd><p>Connects to a database with connection string <dd><p>Connects to a database by connection string</p>
:param connection_string: <blockquote>
:return:</p> <div><dl class="simple">
<dt>connection_string: <code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></dt><dd><p>Database connection string, see: <a class="reference external" href="https://docs.sqlalchemy.org/en/14/core/engines.html">https://docs.sqlalchemy.org/en/14/core/engines.html</a></p>
</dd>
</dl>
</div></blockquote>
</dd></dl> </dd></dl>
<dl class="py method"> <dl class="py method">

View File

@ -236,10 +236,8 @@
<dl class="py method"> <dl class="py method">
<dt id="cpl.database.database_settings.DatabaseSettings.from_dict"> <dt id="cpl.database.database_settings.DatabaseSettings.from_dict">
<code class="sig-name descname"><span class="pre">from_dict</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">settings</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">dict</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#cpl.database.database_settings.DatabaseSettings.from_dict" title="Permalink to this definition"></a></dt> <code class="sig-name descname"><span class="pre">from_dict</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">settings</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">dict</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#cpl.database.database_settings.DatabaseSettings.from_dict" title="Permalink to this definition"></a></dt>
<dd><p>Converts attributes to dict</p> <dd><p>Sets attributes from given dict</p>
<blockquote> <p>settings: <code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p>
<div><p>settings: <code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></p>
</div></blockquote>
</dd></dl> </dd></dl>
</dd></dl> </dd></dl>

File diff suppressed because one or more lines are too long

View File

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

View File

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

View File

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