Skip to content

Commit

Permalink
make close_connections() public
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieTaylor-TUOS committed Feb 9, 2022
1 parent fe17214 commit 915fbae
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A wrapper for the MySQL Python connector that provides additional resilience and functionality.

**Latest version: 1.3.1**
**Latest version: 1.3.2**

## About this repository

Expand Down
6 changes: 3 additions & 3 deletions dbconnector/dbconnector.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def __enter__(self):
return self

def __exit__(self, *args):
self._close_connections()
self.close_connections()

def _test_query(self):
"""
Expand Down Expand Up @@ -357,8 +357,8 @@ def _safe_query(self, query_type, **kwargs):
self.pool._return_connection(cnx)
return result

def _close_connections(self):
"""Close all connections when done for optimal DB efficiency."""
def close_connections(self):
"""Close all connections when finished for optimal DB efficiency."""
self.pool.close_all()

@staticmethod
Expand Down
Binary file modified docs/build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/build/doctrees/modules.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 5a18600babc4a6aa5275e6990457ff3d
config: acc98064fa4a6df7967ad5e1f0b998cc
tags: 645f666f9bcd5a90fca523b33c5a78b7
14 changes: 8 additions & 6 deletions docs/build/html/_modules/dbconnector/dbconnector.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dbconnector.dbconnector &mdash; MySQL-DBConnector 1.3.1 documentation</title>
<title>dbconnector.dbconnector &mdash; MySQL-DBConnector 1.3.2 documentation</title>
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down Expand Up @@ -156,7 +156,8 @@ <h1>Source code for dbconnector.dbconnector</h1><div class="highlight"><pre>
<span class="k">def</span> <span class="nf">_return_connection</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">cnx</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Return a connection to the pool. Incoming connections are tested and if they are no longer</span>
<span class="sd"> usable will be disgarded using *DBConnectionPool._close_connection*, which frees up the slot.</span>
<span class="sd"> usable will be disgarded using *DBConnectionPool._close_connection*, which frees up the</span>
<span class="sd"> slot.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">cnx</span><span class="p">,</span> <span class="n">connection</span><span class="o">.</span><span class="n">MySQLConnection</span><span class="p">)</span> <span class="ow">and</span> <span class="n">cnx</span><span class="o">.</span><span class="n">is_connected</span><span class="p">():</span>
<span class="bp">self</span><span class="o">.</span><span class="n">connection_pool</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">cnx</span><span class="p">)</span>
Expand Down Expand Up @@ -274,7 +275,7 @@ <h1>Source code for dbconnector.dbconnector</h1><div class="highlight"><pre>
<span class="k">return</span> <span class="bp">self</span>

<span class="k">def</span> <span class="fm">__exit__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_close_connections</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">close_connections</span><span class="p">()</span>

<span class="k">def</span> <span class="nf">_test_query</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
Expand Down Expand Up @@ -426,9 +427,9 @@ <h1>Source code for dbconnector.dbconnector</h1><div class="highlight"><pre>
<span class="bp">self</span><span class="o">.</span><span class="n">pool</span><span class="o">.</span><span class="n">_return_connection</span><span class="p">(</span><span class="n">cnx</span><span class="p">)</span>
<span class="k">return</span> <span class="n">result</span>

<span class="k">def</span> <span class="nf">_close_connections</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<div class="viewcode-block" id="DBConnector.close_connections"><a class="viewcode-back" href="../../modules.html#dbconnector.dbconnector.DBConnector.close_connections">[docs]</a> <span class="k">def</span> <span class="nf">close_connections</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Close all connections when done for optimal DB efficiency.&quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">pool</span><span class="o">.</span><span class="n">close_all</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">pool</span><span class="o">.</span><span class="n">close_all</span><span class="p">()</span></div>

<span class="nd">@staticmethod</span>
<span class="k">def</span> <span class="nf">_safe_close</span><span class="p">(</span><span class="n">cnx</span><span class="p">):</span>
Expand Down Expand Up @@ -560,7 +561,8 @@ <h1>Source code for dbconnector.dbconnector</h1><div class="highlight"><pre>
<span class="sd"> int</span>
<span class="sd"> The number of rows affected.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_safe_query</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_iud_query</span><span class="p">,</span> <span class="n">sqlquery</span><span class="o">=</span><span class="n">sqlquery</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">,</span> <span class="n">chunk_size</span><span class="o">=</span><span class="n">chunk_size</span><span class="p">)</span></div></div>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_safe_query</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_iud_query</span><span class="p">,</span> <span class="n">sqlquery</span><span class="o">=</span><span class="n">sqlquery</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">,</span>
<span class="n">chunk_size</span><span class="o">=</span><span class="n">chunk_size</span><span class="p">)</span></div></div>
</pre></div>

</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/build/html/_modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Overview: module code &mdash; MySQL-DBConnector 1.3.1 documentation</title>
<title>Overview: module code &mdash; MySQL-DBConnector 1.3.2 documentation</title>
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
2 changes: 1 addition & 1 deletion docs/build/html/_static/documentation_options.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var DOCUMENTATION_OPTIONS = {
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
VERSION: '1.3.1',
VERSION: '1.3.2',
LANGUAGE: 'None',
COLLAPSE_INDEX: false,
BUILDER: 'html',
Expand Down
13 changes: 11 additions & 2 deletions docs/build/html/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Index &mdash; MySQL-DBConnector 1.3.1 documentation</title>
<title>Index &mdash; MySQL-DBConnector 1.3.2 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down Expand Up @@ -70,12 +70,21 @@
<h1 id="index">Index</h1>

<div class="genindex-jumpbox">
<a href="#D"><strong>D</strong></a>
<a href="#C"><strong>C</strong></a>
| <a href="#D"><strong>D</strong></a>
| <a href="#I"><strong>I</strong></a>
| <a href="#P"><strong>P</strong></a>
| <a href="#Q"><strong>Q</strong></a>

</div>
<h2 id="C">C</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="modules.html#dbconnector.dbconnector.DBConnector.close_connections">close_connections() (dbconnector.dbconnector.DBConnector method)</a>
</li>
</ul></td>
</tr></table>

<h2 id="D">D</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
Expand Down
2 changes: 1 addition & 1 deletion docs/build/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Welcome to MySQL-DBConnector’s documentation! &mdash; MySQL-DBConnector 1.3.1 documentation</title>
<title>Welcome to MySQL-DBConnector’s documentation! &mdash; MySQL-DBConnector 1.3.2 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
8 changes: 7 additions & 1 deletion docs/build/html/modules.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Modules &mdash; MySQL-DBConnector 1.3.1 documentation</title>
<title>Modules &mdash; MySQL-DBConnector 1.3.2 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down Expand Up @@ -124,6 +124,12 @@ <h2><a class="toc-backref" href="#id3">dbconnector</a><a class="headerlink" href
</dl>
<p class="rubric">Notes</p>
<p>Some <cite>connector_args</cite> have no defaults and are always required: ‘user’, ‘password’, ‘database’.</p>
<dl class="py method">
<dt class="sig sig-object py" id="dbconnector.dbconnector.DBConnector.close_connections">
<span class="sig-name descname"><span class="pre">close_connections</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/dbconnector/dbconnector.html#DBConnector.close_connections"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dbconnector.dbconnector.DBConnector.close_connections" title="Permalink to this definition"></a></dt>
<dd><p>Close all connections when done for optimal DB efficiency.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="dbconnector.dbconnector.DBConnector.iud_query">
<span class="sig-name descname"><span class="pre">iud_query</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sqlquery</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">list</span><span class="p"><span class="pre">[</span></span><span class="pre">list</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">chunk_size</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">1000</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/dbconnector/dbconnector.html#DBConnector.iud_query"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dbconnector.dbconnector.DBConnector.iud_query" title="Permalink to this definition"></a></dt>
Expand Down
Binary file modified docs/build/html/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/build/html/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Search &mdash; MySQL-DBConnector 1.3.1 documentation</title>
<title>Search &mdash; MySQL-DBConnector 1.3.2 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />

Expand Down
2 changes: 1 addition & 1 deletion docs/build/html/searchindex.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# The short X.Y version
version = u'1.3'
# The full version, including alpha/beta/rc tags
release = u'1.3.1'
release = u'1.3.2'


# -- General configuration ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version="1.3.1",
version="1.3.2",

description="A wrapper for the MySQL Python connector that provides additional resilience and functionality.",
long_description=long_description,
Expand Down

0 comments on commit 915fbae

Please sign in to comment.