Skip to content

Commit 8833f5d

Browse files
move test query to __init__
Move the call to _test_query() to the __init__ rather than __enter__ in case user does not use the context manager
1 parent 915fbae commit 8833f5d

15 files changed

Lines changed: 16 additions & 16 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

5-
**Latest version: 1.3.2**
5+
**Latest version: 1.3.3**
66

77
## About this repository
88

dbconnector/dbconnector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,13 @@ def __init__(
195195
errorcode.ER_LOCK_WAIT_TIMEOUT,
196196
)
197197
debug(f"config: {self._redacted_connector_args()}")
198+
self._test_query()
198199
self.sleep_interval = sleep_interval
199200
self.cnx_retries = cnx_retries
200201
self.query_log = DBConnectorLog(query_log, self.connector_args)
201202

202203
def __enter__(self):
203204
"""Enter the context manager. Test the connection and log a debug message."""
204-
self._test_query()
205205
return self
206206

207207
def __exit__(self, *args):
4 Bytes
Binary file not shown.
8 Bytes
Binary file not shown.

docs/build/html/.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: acc98064fa4a6df7967ad5e1f0b998cc
3+
config: 29eae65ee8ac16dff350bee6a691b9f1
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

docs/build/html/_modules/dbconnector/dbconnector.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>dbconnector.dbconnector &mdash; MySQL-DBConnector 1.3.2 documentation</title>
6+
<title>dbconnector.dbconnector &mdash; MySQL-DBConnector 1.3.3 documentation</title>
77
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
88
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
99
<!--[if lt IE 9]>
@@ -265,13 +265,13 @@ <h1>Source code for dbconnector.dbconnector</h1><div class="highlight"><pre>
265265
<span class="n">errorcode</span><span class="o">.</span><span class="n">ER_LOCK_WAIT_TIMEOUT</span><span class="p">,</span>
266266
<span class="p">)</span>
267267
<span class="n">debug</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;config: </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_redacted_connector_args</span><span class="p">()</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
268+
<span class="bp">self</span><span class="o">.</span><span class="n">_test_query</span><span class="p">()</span>
268269
<span class="bp">self</span><span class="o">.</span><span class="n">sleep_interval</span> <span class="o">=</span> <span class="n">sleep_interval</span>
269270
<span class="bp">self</span><span class="o">.</span><span class="n">cnx_retries</span> <span class="o">=</span> <span class="n">cnx_retries</span>
270271
<span class="bp">self</span><span class="o">.</span><span class="n">query_log</span> <span class="o">=</span> <span class="n">DBConnectorLog</span><span class="p">(</span><span class="n">query_log</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_args</span><span class="p">)</span>
271272

272273
<span class="k">def</span> <span class="fm">__enter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
273274
<span class="sd">&quot;&quot;&quot;Enter the context manager. Test the connection and log a debug message.&quot;&quot;&quot;</span>
274-
<span class="bp">self</span><span class="o">.</span><span class="n">_test_query</span><span class="p">()</span>
275275
<span class="k">return</span> <span class="bp">self</span>
276276

277277
<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>
@@ -428,7 +428,7 @@ <h1>Source code for dbconnector.dbconnector</h1><div class="highlight"><pre>
428428
<span class="k">return</span> <span class="n">result</span>
429429

430430
<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>
431-
<span class="sd">&quot;&quot;&quot;Close all connections when done for optimal DB efficiency.&quot;&quot;&quot;</span>
431+
<span class="sd">&quot;&quot;&quot;Close all connections when finished for optimal DB efficiency.&quot;&quot;&quot;</span>
432432
<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>
433433

434434
<span class="nd">@staticmethod</span>

docs/build/html/_modules/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>Overview: module code &mdash; MySQL-DBConnector 1.3.2 documentation</title>
6+
<title>Overview: module code &mdash; MySQL-DBConnector 1.3.3 documentation</title>
77
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
88
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
99
<!--[if lt IE 9]>

docs/build/html/_static/documentation_options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var DOCUMENTATION_OPTIONS = {
22
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
3-
VERSION: '1.3.2',
3+
VERSION: '1.3.3',
44
LANGUAGE: 'None',
55
COLLAPSE_INDEX: false,
66
BUILDER: 'html',

docs/build/html/genindex.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>Index &mdash; MySQL-DBConnector 1.3.2 documentation</title>
6+
<title>Index &mdash; MySQL-DBConnector 1.3.3 documentation</title>
77
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
88
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
99
<!--[if lt IE 9]>

docs/build/html/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
55

66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>Welcome to MySQL-DBConnector’s documentation! &mdash; MySQL-DBConnector 1.3.2 documentation</title>
7+
<title>Welcome to MySQL-DBConnector’s documentation! &mdash; MySQL-DBConnector 1.3.3 documentation</title>
88
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
99
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
1010
<!--[if lt IE 9]>

0 commit comments

Comments
 (0)