mirror of
https://github.com/mariadb-corporation/mariadb-connector-python.git
synced 2025-08-07 11:39:43 +00:00
Updated documentation
This commit is contained in:
@ -13,6 +13,8 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import mariadb
|
import mariadb
|
||||||
|
from typing import Sequence
|
||||||
|
from datetime import datetime
|
||||||
print(mariadb.__path__)
|
print(mariadb.__path__)
|
||||||
sys.path.insert(0, os.path.abspath('../..'))
|
sys.path.insert(0, os.path.abspath('../..'))
|
||||||
sys.setrecursionlimit(1500)
|
sys.setrecursionlimit(1500)
|
||||||
@ -21,11 +23,13 @@ sys.setrecursionlimit(1500)
|
|||||||
# -- Project information -----------------------------------------------------
|
# -- Project information -----------------------------------------------------
|
||||||
|
|
||||||
project = 'MariaDB Connector/Python'
|
project = 'MariaDB Connector/Python'
|
||||||
copyright = '2019-2021 MariaDB Corporation and Georg Richter'
|
copyright = '2019-%s MariaDB Corporation and Georg Richter' % datetime.now().year
|
||||||
author = 'Georg Richter'
|
author = 'Georg Richter'
|
||||||
|
|
||||||
# The full version, including alpha/beta/rc tags
|
# The full version, including alpha/beta/rc tags
|
||||||
release = '1.1.0-alpha'
|
release = mariadb.__version__
|
||||||
|
if len(mariadb.__version_info__) > 3:
|
||||||
|
release= release + "-" + mariadb.__version_info__[3]
|
||||||
|
|
||||||
|
|
||||||
# -- General configuration ---------------------------------------------------
|
# -- General configuration ---------------------------------------------------
|
||||||
@ -33,8 +37,7 @@ release = '1.1.0-alpha'
|
|||||||
# Add any Sphinx extension module names here, as strings. They can be
|
# Add any Sphinx extension module names here, as strings. They can be
|
||||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||||
# ones.
|
# ones.
|
||||||
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'recommonmark'
|
extensions = ['sphinx.ext.napoleon', 'sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'recommonmark' ]
|
||||||
]
|
|
||||||
|
|
||||||
# Add any paths that contain templates here, relative to this directory.
|
# Add any paths that contain templates here, relative to this directory.
|
||||||
templates_path = ['_templates']
|
templates_path = ['_templates']
|
||||||
|
@ -13,7 +13,7 @@ Connection constructors
|
|||||||
.. automethod:: mariadb.connections.Connection.cursor
|
.. automethod:: mariadb.connections.Connection.cursor
|
||||||
|
|
||||||
.. versionadded:: 1.0.1
|
.. versionadded:: 1.0.1
|
||||||
.. automethod:: mariadb.connections.Connection.xid(format_id: int, global_transaction_id: str, brach_qualifier: str)
|
.. automethod:: mariadb.connections.Connection.xid
|
||||||
|
|
||||||
------------------
|
------------------
|
||||||
Connection methods
|
Connection methods
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
The cursor class
|
The cursor class
|
||||||
====================
|
====================
|
||||||
|
.. sectionauthor:: Georg Richter <georg@mariadb.com>
|
||||||
|
|
||||||
.. autoclass:: mariadb.cursors.Cursor
|
.. autoclass:: mariadb.cursors.Cursor
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
@ -1,53 +1,30 @@
|
|||||||
|
========================
|
||||||
The ConnectionPool class
|
The ConnectionPool class
|
||||||
========================
|
========================
|
||||||
|
|
||||||
.. sectionauthor:: Georg Richter <georg@mariadb.com>
|
.. sectionauthor:: Georg Richter <georg@mariadb.com>
|
||||||
|
|
||||||
.. class:: ConnectionPool
|
.. autoclass:: mariadb.ConnectionPool
|
||||||
|
|
||||||
MariaDB Connector/Python supports simple connection pooling.
|
-----------------------
|
||||||
A connection pool holds a number of open connections and handles thread safety
|
Connection pool methods
|
||||||
when providing connections to threads.
|
-----------------------
|
||||||
|
|
||||||
The size of a connection pool is configurable at creation time, but cannot be
|
.. automethod:: mariadb.ConnectionPool.add_connection
|
||||||
changed afterwards. The maximum size of a connection pool is limited to 64 connections.
|
|
||||||
|
|
||||||
.. method:: add_connection(connection)
|
.. automethod:: mariadb.ConnectionPool.close
|
||||||
|
|
||||||
Adds a connection object to the connection pool.
|
.. automethod:: mariadb.ConnectionPool.get_connection
|
||||||
|
|
||||||
In case that pool doesn't have a free slot or is not configured a PoolError
|
.. automethod:: mariadb.ConnectionPool.set_config
|
||||||
exception will be raised.
|
|
||||||
|
|
||||||
.. method:: close()
|
--------------------------
|
||||||
|
Connection pool attributes
|
||||||
|
--------------------------
|
||||||
|
|
||||||
Closes the pool and all connection inside the pool.
|
.. autoattribute:: mariadb.ConnectionPool.max_size
|
||||||
.. versionadded:: 1.0.1
|
|
||||||
|
|
||||||
.. method:: get_connection()
|
.. autoattribute:: mariadb.ConnectionPool.pool_size
|
||||||
|
|
||||||
Returns a connection from the connection pool or raises a PoolError if no
|
.. autoattribute:: mariadb.ConnectionPool.pool_name
|
||||||
connection is available.
|
|
||||||
|
|
||||||
.. method:: set_config(\*\*kwargs)
|
|
||||||
|
|
||||||
Sets the connection configuration for the connection pool. For valid connection
|
|
||||||
arguments see :func:`mariadb.connect` method.
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
This method doesn't create connections in the pool. To fill the pool one has to use
|
|
||||||
the :func:`add_connection` ḿethod.
|
|
||||||
|
|
||||||
.. data:: max_size
|
|
||||||
|
|
||||||
Returns the maximum allowed size of the pool
|
|
||||||
|
|
||||||
.. data:: pool_size
|
|
||||||
|
|
||||||
Returns the size of connection pool
|
|
||||||
|
|
||||||
.. data:: pool_name
|
|
||||||
|
|
||||||
Returns the name of the pool.
|
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ Connection constructors
|
|||||||
.. automethod:: mariadb.connections.Connection.cursor
|
.. automethod:: mariadb.connections.Connection.cursor
|
||||||
|
|
||||||
.. versionadded:: 1.0.1
|
.. versionadded:: 1.0.1
|
||||||
.. automethod:: mariadb.connections.Connection.xid(format_id: int, global_transaction_id: str, brach_qualifier: str)
|
.. automethod:: mariadb.connections.Connection.xid
|
||||||
|
|
||||||
------------------
|
------------------
|
||||||
Connection methods
|
Connection methods
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
The cursor class
|
The cursor class
|
||||||
====================
|
====================
|
||||||
|
.. sectionauthor:: Georg Richter <georg@mariadb.com>
|
||||||
|
|
||||||
.. autoclass:: mariadb.cursors.Cursor
|
.. autoclass:: mariadb.cursors.Cursor
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
@ -1,53 +1,30 @@
|
|||||||
|
========================
|
||||||
The ConnectionPool class
|
The ConnectionPool class
|
||||||
========================
|
========================
|
||||||
|
|
||||||
.. sectionauthor:: Georg Richter <georg@mariadb.com>
|
.. sectionauthor:: Georg Richter <georg@mariadb.com>
|
||||||
|
|
||||||
.. class:: ConnectionPool
|
.. autoclass:: mariadb.ConnectionPool
|
||||||
|
|
||||||
MariaDB Connector/Python supports simple connection pooling.
|
-----------------------
|
||||||
A connection pool holds a number of open connections and handles thread safety
|
Connection pool methods
|
||||||
when providing connections to threads.
|
-----------------------
|
||||||
|
|
||||||
The size of a connection pool is configurable at creation time, but cannot be
|
.. automethod:: mariadb.ConnectionPool.add_connection
|
||||||
changed afterwards. The maximum size of a connection pool is limited to 64 connections.
|
|
||||||
|
|
||||||
.. method:: add_connection(connection)
|
.. automethod:: mariadb.ConnectionPool.close
|
||||||
|
|
||||||
Adds a connection object to the connection pool.
|
.. automethod:: mariadb.ConnectionPool.get_connection
|
||||||
|
|
||||||
In case that pool doesn't have a free slot or is not configured a PoolError
|
.. automethod:: mariadb.ConnectionPool.set_config
|
||||||
exception will be raised.
|
|
||||||
|
|
||||||
.. method:: close()
|
--------------------------
|
||||||
|
Connection pool attributes
|
||||||
|
--------------------------
|
||||||
|
|
||||||
Closes the pool and all connection inside the pool.
|
.. autoattribute:: mariadb.ConnectionPool.max_size
|
||||||
.. versionadded:: 1.0.1
|
|
||||||
|
|
||||||
.. method:: get_connection()
|
.. autoattribute:: mariadb.ConnectionPool.pool_size
|
||||||
|
|
||||||
Returns a connection from the connection pool or raises a PoolError if no
|
.. autoattribute:: mariadb.ConnectionPool.pool_name
|
||||||
connection is available.
|
|
||||||
|
|
||||||
.. method:: set_config(\*\*kwargs)
|
|
||||||
|
|
||||||
Sets the connection configuration for the connection pool. For valid connection
|
|
||||||
arguments see :func:`mariadb.connect` method.
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
This method doesn't create connections in the pool. To fill the pool one has to use
|
|
||||||
the :func:`add_connection` ḿethod.
|
|
||||||
|
|
||||||
.. data:: max_size
|
|
||||||
|
|
||||||
Returns the maximum allowed size of the pool
|
|
||||||
|
|
||||||
.. data:: pool_size
|
|
||||||
|
|
||||||
Returns the size of connection pool
|
|
||||||
|
|
||||||
.. data:: pool_name
|
|
||||||
|
|
||||||
Returns the name of the pool.
|
|
||||||
|
|
||||||
|
@ -83,10 +83,10 @@ method was called. Further calls to execute() method will ignore the sql stateme
|
|||||||
<li><p>binary= False
|
<li><p>binary= False
|
||||||
Always execute statement in MariaDB client/server binary protocol.</p></li>
|
Always execute statement in MariaDB client/server binary protocol.</p></li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>In versions prior to 1.1.0 results were unbuffered by default, which means before executing another
|
<p>In versions prior to 1.1.0 results were unbuffered by default, which means before executing another
|
||||||
statement with the same connection the entire result set must be fetched.</p>
|
statement with the same connection the entire result set must be fetched.</p>
|
||||||
<p>fetch* methods of the cursor class by default return result set values as a
|
<p>fetch* methods of the cursor class by default return result set values as a
|
||||||
tuple, unless named_tuple or dictionary was specified. The latter one exists
|
tuple, unless named_tuple or dictionary was specified. The latter one exists
|
||||||
for compatibility reasons and should be avoided due to possible inconsistency
|
for compatibility reasons and should be avoided due to possible inconsistency
|
||||||
in case two or more fields in a result set have the same name.</p>
|
in case two or more fields in a result set have the same name.</p>
|
||||||
<p>If cursor_type is set to CURSOR_TYPE.READ_ONLY, a cursor is opened for
|
<p>If cursor_type is set to CURSOR_TYPE.READ_ONLY, a cursor is opened for
|
||||||
@ -98,17 +98,13 @@ the statement invoked with cursors execute() method.</p>
|
|||||||
</div>
|
</div>
|
||||||
<dl class="py method">
|
<dl class="py method">
|
||||||
<dt class="sig sig-object py" id="mariadb.connections.Connection.xid">
|
<dt class="sig sig-object py" id="mariadb.connections.Connection.xid">
|
||||||
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">xid</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">format_id</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">global_transaction_id</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">brach_qualifier</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="#mariadb.connections.Connection.xid" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">xid</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">format_id</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">global_transaction_id</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">branch_qualifier</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mariadb.connections.Connection.xid" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>A transaction ID object suitable for passing to the .tpc_*()
|
<dd><p>A transaction ID object suitable for passing to the .tpc_*()
|
||||||
methods of this connection.</p>
|
methods of this connection.</p>
|
||||||
<dl class="simple">
|
<p>Parameters:
|
||||||
<dt>Parameters:</dt><dd><ul class="simple">
|
:param int format_id: Format id. If not set default value <cite>0</cite> will be used.
|
||||||
<li><p>format_id: Format id. If not set default value <cite>0</cite> will be used.</p></li>
|
:param str global_transaction_id: Global transaction qualifier, which must be unique. The maximum length of the global transaction id is limited to 64 characters.
|
||||||
<li><p>global_transaction_id: Global transaction qualifier, which must be unique. The maximum length of the global transaction id is limited to 64 characters.</p></li>
|
:param str branch_qualifier: Branch qualifier which represents a local transaction identifier. The maximum length of the branch qualifier is limited to 64 characters.</p>
|
||||||
<li><p>branch_qualifier: Branch qualifier which represents a local transaction identifier. The maximum length of the branch qualifier is limited to 64 characters.</p></li>
|
|
||||||
</ul>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</dd></dl>
|
</dd></dl>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -134,11 +130,12 @@ or cancelled by .rollback() method.</p>
|
|||||||
<dt class="sig sig-object py" id="mariadb.connections.Connection.change_user">
|
<dt class="sig sig-object py" id="mariadb.connections.Connection.change_user">
|
||||||
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">change_user</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">user</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">password</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">database</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mariadb.connections.Connection.change_user" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">change_user</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">user</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">password</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">database</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mariadb.connections.Connection.change_user" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Changes the user and default database of the current connection</p>
|
<dd><p>Changes the user and default database of the current connection</p>
|
||||||
<dl class="simple">
|
<dl class="field-list simple">
|
||||||
<dt>Parameters:</dt><dd><ul class="simple">
|
<dt class="field-odd">Parameters</dt>
|
||||||
<li><p>user: user name</p></li>
|
<dd class="field-odd"><ul class="simple">
|
||||||
<li><p>password: password</p></li>
|
<li><p><strong>user</strong> (<em>-</em>) – user name</p></li>
|
||||||
<li><p>database: name of default database</p></li>
|
<li><p><strong>password</strong> (<em>-</em>) – password</p></li>
|
||||||
|
<li><p><strong>database</strong> (<em>-</em>) – name of default database</p></li>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@ -187,10 +184,10 @@ method was called. Further calls to execute() method will ignore the sql stateme
|
|||||||
<li><p>binary= False
|
<li><p>binary= False
|
||||||
Always execute statement in MariaDB client/server binary protocol.</p></li>
|
Always execute statement in MariaDB client/server binary protocol.</p></li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>In versions prior to 1.1.0 results were unbuffered by default, which means before executing another
|
<p>In versions prior to 1.1.0 results were unbuffered by default, which means before executing another
|
||||||
statement with the same connection the entire result set must be fetched.</p>
|
statement with the same connection the entire result set must be fetched.</p>
|
||||||
<p>fetch* methods of the cursor class by default return result set values as a
|
<p>fetch* methods of the cursor class by default return result set values as a
|
||||||
tuple, unless named_tuple or dictionary was specified. The latter one exists
|
tuple, unless named_tuple or dictionary was specified. The latter one exists
|
||||||
for compatibility reasons and should be avoided due to possible inconsistency
|
for compatibility reasons and should be avoided due to possible inconsistency
|
||||||
in case two or more fields in a result set have the same name.</p>
|
in case two or more fields in a result set have the same name.</p>
|
||||||
<p>If cursor_type is set to CURSOR_TYPE.READ_ONLY, a cursor is opened for
|
<p>If cursor_type is set to CURSOR_TYPE.READ_ONLY, a cursor is opened for
|
||||||
@ -269,7 +266,7 @@ or the storage engine does not support transactions.”</p>
|
|||||||
</div>
|
</div>
|
||||||
<dl class="py method">
|
<dl class="py method">
|
||||||
<dt class="sig sig-object py" id="mariadb.connections.Connection.select_db">
|
<dt class="sig sig-object py" id="mariadb.connections.Connection.select_db">
|
||||||
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">select_db</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">new_db</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mariadb.connections.Connection.select_db" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">select_db</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">new_db</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="#mariadb.connections.Connection.select_db" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Gets the default database for the current connection.</p>
|
<dd><p>Gets the default database for the current connection.</p>
|
||||||
<p>The default database can also be obtained or changed by database attribute.</p>
|
<p>The default database can also be obtained or changed by database attribute.</p>
|
||||||
</dd></dl>
|
</dd></dl>
|
||||||
|
@ -56,12 +56,20 @@
|
|||||||
<h2>Cursor methods<a class="headerlink" href="#cursor-methods" title="Permalink to this headline">¶</a></h2>
|
<h2>Cursor methods<a class="headerlink" href="#cursor-methods" title="Permalink to this headline">¶</a></h2>
|
||||||
<dl class="py method">
|
<dl class="py method">
|
||||||
<dt class="sig sig-object py" id="mariadb.cursors.Cursor.callproc">
|
<dt class="sig sig-object py" id="mariadb.cursors.Cursor.callproc">
|
||||||
<span class="sig-prename descclassname"><span class="pre">Cursor.</span></span><span class="sig-name descname"><span class="pre">callproc</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sp</span></span><span class="p"><span class="pre">:</span></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="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">()</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mariadb.cursors.Cursor.callproc" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">Cursor.</span></span><span class="sig-name descname"><span class="pre">callproc</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sp</span></span><span class="p"><span class="pre">:</span></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="n"><span class="pre">Sequence</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">()</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mariadb.cursors.Cursor.callproc" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Executes a stored procedure sp. The data sequence must contain an entry for
|
<dd><p>Executes a stored procedure sp. The data sequence must contain an entry for
|
||||||
each parameter the procedure expects.</p>
|
each parameter the procedure expects.</p>
|
||||||
<p>Input/Output or Output parameters have to be retrieved by .fetch methods,
|
<p>Input/Output or Output parameters have to be retrieved by .fetch methods,
|
||||||
the .sp_outparams attribute indicates if the result set contains output”
|
the .sp_outparams attribute indicates if the result set contains output
|
||||||
parameters</p>
|
parameters.</p>
|
||||||
|
<dl class="field-list simple">
|
||||||
|
<dt class="field-odd">Parameters</dt>
|
||||||
|
<dd class="field-odd"><ul class="simple">
|
||||||
|
<li><p><strong>sp</strong> – Name of stored procedure.</p></li>
|
||||||
|
<li><p><strong>data</strong> – Optional sequence containing data for placeholder substitution.</p></li>
|
||||||
|
</ul>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
<p>Example:</p>
|
<p>Example:</p>
|
||||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="go">>>>cursor.execute("CREATE PROCEDURE p1(IN i1 VAR CHAR(20), OUT o2 VARCHAR(40))"</span>
|
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="go">>>>cursor.execute("CREATE PROCEDURE p1(IN i1 VAR CHAR(20), OUT o2 VARCHAR(40))"</span>
|
||||||
<span class="go"> "BEGIN"</span>
|
<span class="go"> "BEGIN"</span>
|
||||||
@ -85,7 +93,7 @@ parameters</p>
|
|||||||
|
|
||||||
<dl class="py method">
|
<dl class="py method">
|
||||||
<dt class="sig sig-object py" id="mariadb.cursors.Cursor.execute">
|
<dt class="sig sig-object py" id="mariadb.cursors.Cursor.execute">
|
||||||
<span class="sig-prename descclassname"><span class="pre">Cursor.</span></span><span class="sig-name descname"><span class="pre">execute</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">statement</span></span><span class="p"><span class="pre">:</span></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="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">()</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">buffered</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mariadb.cursors.Cursor.execute" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">Cursor.</span></span><span class="sig-name descname"><span class="pre">execute</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">statement</span></span><span class="p"><span class="pre">:</span></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="n"><span class="pre">Sequence</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">()</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">buffered</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mariadb.cursors.Cursor.execute" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Prepare and execute a SQL statement.</p>
|
<dd><p>Prepare and execute a SQL statement.</p>
|
||||||
<p>Parameters may be provided as sequence or mapping and will be bound
|
<p>Parameters may be provided as sequence or mapping and will be bound
|
||||||
to variables in the operation. Variables are specified as question
|
to variables in the operation. Variables are specified as question
|
||||||
@ -98,7 +106,7 @@ If the cursor was created with attribute prepared=True the statement
|
|||||||
string for following execute operations will be ignored.
|
string for following execute operations will be ignored.
|
||||||
This is most effective for algorithms where the same operation is used,
|
This is most effective for algorithms where the same operation is used,
|
||||||
but different parameters are bound to it (many times).</p>
|
but different parameters are bound to it (many times).</p>
|
||||||
<p>By default execute() method generates an unbuffered result set for
|
<p>By default execute() method generates an unbuffered result set for
|
||||||
statements which return data, setting optional parameter buffered to
|
statements which return data, setting optional parameter buffered to
|
||||||
True will generate buffered result sets.</p>
|
True will generate buffered result sets.</p>
|
||||||
</dd></dl>
|
</dd></dl>
|
||||||
@ -140,25 +148,25 @@ tuple represents data of a row within a table.
|
|||||||
<dl class="py method">
|
<dl class="py method">
|
||||||
<dt class="sig sig-object py" id="mariadb.cursors.Cursor.fetchall">
|
<dt class="sig sig-object py" id="mariadb.cursors.Cursor.fetchall">
|
||||||
<span class="sig-prename descclassname"><span class="pre">Cursor.</span></span><span class="sig-name descname"><span class="pre">fetchall</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mariadb.cursors.Cursor.fetchall" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">Cursor.</span></span><span class="sig-name descname"><span class="pre">fetchall</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mariadb.cursors.Cursor.fetchall" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Fetch all remaining rows of a query result, returning them as a
|
<dd><p>Fetch all remaining rows of a query result, returning them as a
|
||||||
sequence of sequences (e.g. a list of tuples).</p>
|
sequence of sequences (e.g. a list of tuples).</p>
|
||||||
<p>An exception will be raised if the previous call to execute() didn’t
|
<p>An exception will be raised if the previous call to execute() didn’t
|
||||||
produce a result set or execute() wasn’t called before.</p>
|
produce a result set or execute() wasn’t called before.</p>
|
||||||
</dd></dl>
|
</dd></dl>
|
||||||
|
|
||||||
<dl class="py method">
|
<dl class="py method">
|
||||||
<dt class="sig sig-object py" id="mariadb.cursors.Cursor.fetchmany">
|
<dt class="sig sig-object py" id="mariadb.cursors.Cursor.fetchmany">
|
||||||
<span class="sig-prename descclassname"><span class="pre">Cursor.</span></span><span class="sig-name descname"><span class="pre">fetchmany</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mariadb.cursors.Cursor.fetchmany" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">Cursor.</span></span><span class="sig-name descname"><span class="pre">fetchmany</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">size</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mariadb.cursors.Cursor.fetchmany" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Fetch the next set of rows of a query result, returning a sequence
|
<dd><p>Fetch the next set of rows of a query result, returning a sequence
|
||||||
of sequences (e.g. a list of tuples). An empty sequence is returned
|
of sequences (e.g. a list of tuples). An empty sequence is returned
|
||||||
when no more rows are available.</p>
|
when no more rows are available.</p>
|
||||||
<p>The number of rows to fetch per call is specified by the parameter.
|
<p>The number of rows to fetch per call is specified by the parameter.
|
||||||
If it is not given, the cursor’s arraysize determines the number
|
If it is not given, the cursor’s arraysize determines the number
|
||||||
of rows to be fetched. The method should try to fetch as many rows
|
of rows to be fetched. The method should try to fetch as many rows
|
||||||
as indicated by the size parameter.
|
as indicated by the size parameter.
|
||||||
If this is not possible due to the specified number of rows not being
|
If this is not possible due to the specified number of rows not being
|
||||||
available, fewer rows may be returned.</p>
|
available, fewer rows may be returned.</p>
|
||||||
<p>An exception will be raised if the previous call to execute() didn’t
|
<p>An exception will be raised if the previous call to execute() didn’t
|
||||||
produce a result set or execute() wasn’t called before.</p>
|
produce a result set or execute() wasn’t called before.</p>
|
||||||
</dd></dl>
|
</dd></dl>
|
||||||
|
|
||||||
@ -167,7 +175,7 @@ produce a result set or execute() wasn’t called before.</p>
|
|||||||
<span class="sig-prename descclassname"><span class="pre">Cursor.</span></span><span class="sig-name descname"><span class="pre">fetchone</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mariadb.cursors.Cursor.fetchone" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">Cursor.</span></span><span class="sig-name descname"><span class="pre">fetchone</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mariadb.cursors.Cursor.fetchone" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Fetch the next row of a query result set, returning a single sequence,
|
<dd><p>Fetch the next row of a query result set, returning a single sequence,
|
||||||
or None if no more data is available.</p>
|
or None if no more data is available.</p>
|
||||||
<p>An exception will be raised if the previous call to execute() didn’t
|
<p>An exception will be raised if the previous call to execute() didn’t
|
||||||
produce a result set or execute() wasn’t called before.</p>
|
produce a result set or execute() wasn’t called before.</p>
|
||||||
</dd></dl>
|
</dd></dl>
|
||||||
|
|
||||||
@ -187,7 +195,7 @@ discarding any remaining rows from the current set.</p>
|
|||||||
|
|
||||||
<dl class="py method">
|
<dl class="py method">
|
||||||
<dt class="sig sig-object py" id="mariadb.cursors.Cursor.scroll">
|
<dt class="sig sig-object py" id="mariadb.cursors.Cursor.scroll">
|
||||||
<span class="sig-prename descclassname"><span class="pre">Cursor.</span></span><span class="sig-name descname"><span class="pre">scroll</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'relative'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mariadb.cursors.Cursor.scroll" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">Cursor.</span></span><span class="sig-name descname"><span class="pre">scroll</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'relative'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mariadb.cursors.Cursor.scroll" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Scroll the cursor in the result set to a new position according to mode.</p>
|
<dd><p>Scroll the cursor in the result set to a new position according to mode.</p>
|
||||||
<p>If mode is “relative” (default), value is taken as offset to the current
|
<p>If mode is “relative” (default), value is taken as offset to the current
|
||||||
position in the result set, if set to absolute, value states an absolute
|
position in the result set, if set to absolute, value states an absolute
|
||||||
|
@ -65,7 +65,7 @@
|
|||||||
<h2 id="A">A</h2>
|
<h2 id="A">A</h2>
|
||||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||||
<td style="width: 33%; vertical-align: top;"><ul>
|
<td style="width: 33%; vertical-align: top;"><ul>
|
||||||
<li><a href="pool.html#ConnectionPool.add_connection">add_connection() (ConnectionPool method)</a>
|
<li><a href="pool.html#mariadb.ConnectionPool.add_connection">add_connection() (mariadb.ConnectionPool method)</a>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="module.html#mariadb.apilevel">apilevel (in module mariadb)</a>
|
<li><a href="module.html#mariadb.apilevel">apilevel (in module mariadb)</a>
|
||||||
</li>
|
</li>
|
||||||
@ -107,7 +107,7 @@
|
|||||||
</li>
|
</li>
|
||||||
<li><a href="connection.html#mariadb.connections.Connection.client_capabilities">client_capabilities (mariadb.connections.Connection attribute)</a>
|
<li><a href="connection.html#mariadb.connections.Connection.client_capabilities">client_capabilities (mariadb.connections.Connection attribute)</a>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="pool.html#ConnectionPool.close">close() (ConnectionPool method)</a>
|
<li><a href="pool.html#mariadb.ConnectionPool.close">close() (mariadb.ConnectionPool method)</a>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="connection.html#mariadb.connections.Connection.close">(mariadb.connections.Connection method)</a>
|
<li><a href="connection.html#mariadb.connections.Connection.close">(mariadb.connections.Connection method)</a>
|
||||||
@ -119,25 +119,19 @@
|
|||||||
</li>
|
</li>
|
||||||
<li><a href="connection.html#mariadb.connections.Connection.commit">commit() (mariadb.connections.Connection method)</a>
|
<li><a href="connection.html#mariadb.connections.Connection.commit">commit() (mariadb.connections.Connection method)</a>
|
||||||
</li>
|
</li>
|
||||||
|
</ul></td>
|
||||||
|
<td style="width: 33%; vertical-align: top;"><ul>
|
||||||
<li><a href="module.html#mariadb.connect">connect() (in module mariadb)</a>
|
<li><a href="module.html#mariadb.connect">connect() (in module mariadb)</a>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="connection.html#mariadb.connections.Connection">Connection (class in mariadb.connections)</a>
|
<li><a href="connection.html#mariadb.connections.Connection">Connection (class in mariadb.connections)</a>
|
||||||
</li>
|
</li>
|
||||||
</ul></td>
|
|
||||||
<td style="width: 33%; vertical-align: top;"><ul>
|
|
||||||
<li><a href="cursor.html#mariadb.cursors.Cursor.connection">connection (mariadb.cursors.Cursor attribute)</a>
|
<li><a href="cursor.html#mariadb.cursors.Cursor.connection">connection (mariadb.cursors.Cursor attribute)</a>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="connection.html#mariadb.connections.Connection.connection_id">connection_id (mariadb.connections.Connection attribute)</a>
|
<li><a href="connection.html#mariadb.connections.Connection.connection_id">connection_id (mariadb.connections.Connection attribute)</a>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="pool.html#ConnectionPool">ConnectionPool (built-in class)</a>
|
<li><a href="pool.html#mariadb.ConnectionPool">ConnectionPool (class in mariadb)</a>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="module.html#mariadb.ConnectionPool">ConnectionPool() (in module mariadb)</a>
|
<li><a href="module.html#mariadb.ConnectionPool">ConnectionPool() (in module mariadb)</a>
|
||||||
</li>
|
|
||||||
<li><a href="pool.html#ConnectionPool.max_size">ConnectionPool.max_size (built-in variable)</a>
|
|
||||||
</li>
|
|
||||||
<li><a href="pool.html#ConnectionPool.pool_name">ConnectionPool.pool_name (built-in variable)</a>
|
|
||||||
</li>
|
|
||||||
<li><a href="pool.html#ConnectionPool.pool_size">ConnectionPool.pool_size (built-in variable)</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li><a href="cursor.html#mariadb.cursors.Cursor">Cursor (class in mariadb.cursors)</a>
|
<li><a href="cursor.html#mariadb.cursors.Cursor">Cursor (class in mariadb.cursors)</a>
|
||||||
</li>
|
</li>
|
||||||
@ -287,7 +281,7 @@
|
|||||||
<h2 id="G">G</h2>
|
<h2 id="G">G</h2>
|
||||||
<table style="width: 100%" class="indextable genindextable"><tr>
|
<table style="width: 100%" class="indextable genindextable"><tr>
|
||||||
<td style="width: 33%; vertical-align: top;"><ul>
|
<td style="width: 33%; vertical-align: top;"><ul>
|
||||||
<li><a href="pool.html#ConnectionPool.get_connection">get_connection() (ConnectionPool method)</a>
|
<li><a href="pool.html#mariadb.ConnectionPool.get_connection">get_connection() (mariadb.ConnectionPool method)</a>
|
||||||
</li>
|
</li>
|
||||||
</ul></td>
|
</ul></td>
|
||||||
<td style="width: 33%; vertical-align: top;"><ul>
|
<td style="width: 33%; vertical-align: top;"><ul>
|
||||||
@ -344,9 +338,11 @@
|
|||||||
<li><a href="module.html#module-mariadb">module</a>
|
<li><a href="module.html#module-mariadb">module</a>
|
||||||
</li>
|
</li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
|
<li><a href="module.html#mariadb.mariadbapi_version">mariadbapi_version (in module mariadb)</a>
|
||||||
|
</li>
|
||||||
</ul></td>
|
</ul></td>
|
||||||
<td style="width: 33%; vertical-align: top;"><ul>
|
<td style="width: 33%; vertical-align: top;"><ul>
|
||||||
<li><a href="module.html#mariadb.mariadbapi_version">mariadbapi_version (in module mariadb)</a>
|
<li><a href="pool.html#mariadb.ConnectionPool.max_size">max_size (mariadb.ConnectionPool attribute)</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
module
|
module
|
||||||
@ -392,10 +388,14 @@
|
|||||||
<li><a href="cursor.html#mariadb.cursors.Cursor.paramcount">paramcount (mariadb.cursors.Cursor attribute)</a>
|
<li><a href="cursor.html#mariadb.cursors.Cursor.paramcount">paramcount (mariadb.cursors.Cursor attribute)</a>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="module.html#mariadb.paramstyle">paramstyle (in module mariadb)</a>
|
<li><a href="module.html#mariadb.paramstyle">paramstyle (in module mariadb)</a>
|
||||||
|
</li>
|
||||||
|
<li><a href="connection.html#mariadb.connections.Connection.ping">ping() (mariadb.connections.Connection method)</a>
|
||||||
</li>
|
</li>
|
||||||
</ul></td>
|
</ul></td>
|
||||||
<td style="width: 33%; vertical-align: top;"><ul>
|
<td style="width: 33%; vertical-align: top;"><ul>
|
||||||
<li><a href="connection.html#mariadb.connections.Connection.ping">ping() (mariadb.connections.Connection method)</a>
|
<li><a href="pool.html#mariadb.ConnectionPool.pool_name">pool_name (mariadb.ConnectionPool attribute)</a>
|
||||||
|
</li>
|
||||||
|
<li><a href="pool.html#mariadb.ConnectionPool.pool_size">pool_size (mariadb.ConnectionPool attribute)</a>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="module.html#mariadb.PoolError">PoolError</a>
|
<li><a href="module.html#mariadb.PoolError">PoolError</a>
|
||||||
</li>
|
</li>
|
||||||
@ -443,7 +443,7 @@
|
|||||||
</li>
|
</li>
|
||||||
<li><a href="connection.html#mariadb.connections.Connection.server_version_info">server_version_info (mariadb.connections.Connection attribute)</a>
|
<li><a href="connection.html#mariadb.connections.Connection.server_version_info">server_version_info (mariadb.connections.Connection attribute)</a>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="pool.html#ConnectionPool.set_config">set_config() (ConnectionPool method)</a>
|
<li><a href="pool.html#mariadb.ConnectionPool.set_config">set_config() (mariadb.ConnectionPool method)</a>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="cursor.html#mariadb.cursors.Cursor.setinputsizes">setinputsizes() (mariadb.cursors.Cursor method)</a>
|
<li><a href="cursor.html#mariadb.cursors.Cursor.setinputsizes">setinputsizes() (mariadb.cursors.Cursor method)</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -76,7 +76,11 @@ client library for client server communication.</p>
|
|||||||
<li class="toctree-l2"><a class="reference internal" href="cursor.html#cursor-attributes">Cursor attributes</a></li>
|
<li class="toctree-l2"><a class="reference internal" href="cursor.html#cursor-attributes">Cursor attributes</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li class="toctree-l1"><a class="reference internal" href="pool.html">The ConnectionPool class</a></li>
|
<li class="toctree-l1"><a class="reference internal" href="pool.html">The ConnectionPool class</a><ul>
|
||||||
|
<li class="toctree-l2"><a class="reference internal" href="pool.html#connection-pool-methods">Connection pool methods</a></li>
|
||||||
|
<li class="toctree-l2"><a class="reference internal" href="pool.html#connection-pool-attributes">Connection pool attributes</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
<li class="toctree-l1"><a class="reference internal" href="constants.html">Constants</a><ul>
|
<li class="toctree-l1"><a class="reference internal" href="constants.html">Constants</a><ul>
|
||||||
<li class="toctree-l2"><a class="reference internal" href="constants.html#command">COMMAND</a></li>
|
<li class="toctree-l2"><a class="reference internal" href="constants.html#command">COMMAND</a></li>
|
||||||
<li class="toctree-l2"><a class="reference internal" href="constants.html#client">CLIENT</a></li>
|
<li class="toctree-l2"><a class="reference internal" href="constants.html#client">CLIENT</a></li>
|
||||||
|
BIN
docs/objects.inv
BIN
docs/objects.inv
Binary file not shown.
124
docs/pool.html
124
docs/pool.html
@ -47,69 +47,80 @@
|
|||||||
<div class="section" id="the-connectionpool-class">
|
<div class="section" id="the-connectionpool-class">
|
||||||
<h1>The ConnectionPool class<a class="headerlink" href="#the-connectionpool-class" title="Permalink to this headline">¶</a></h1>
|
<h1>The ConnectionPool class<a class="headerlink" href="#the-connectionpool-class" title="Permalink to this headline">¶</a></h1>
|
||||||
<dl class="py class">
|
<dl class="py class">
|
||||||
<dt class="sig sig-object py" id="ConnectionPool">
|
<dt class="sig sig-object py" id="mariadb.ConnectionPool">
|
||||||
<em class="property"><span class="pre">class</span> </em><span class="sig-name descname"><span class="pre">ConnectionPool</span></span><a class="headerlink" href="#ConnectionPool" title="Permalink to this definition">¶</a></dt>
|
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">mariadb.</span></span><span class="sig-name descname"><span class="pre">ConnectionPool</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mariadb.ConnectionPool" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>MariaDB Connector/Python supports simple connection pooling.
|
<dd><p>Class defining a pool of database connections</p>
|
||||||
A connection pool holds a number of open connections and handles thread safety
|
<p>MariaDB Connector/Python supports simple connection pooling.
|
||||||
when providing connections to threads.</p>
|
A connection pool holds a number of open connections and handles
|
||||||
<p>The size of a connection pool is configurable at creation time, but cannot be
|
thread safety when providing connections to threads.</p>
|
||||||
changed afterwards. The maximum size of a connection pool is limited to 64 connections.</p>
|
<p>The size of a connection pool is configurable at creation time,
|
||||||
|
but cannot be changed afterwards. The maximum size of a connection
|
||||||
|
pool is limited to 64 connections.</p>
|
||||||
|
<dl class="field-list simple">
|
||||||
|
<dt class="field-odd">Keyword Arguments</dt>
|
||||||
|
<dd class="field-odd"><ul class="simple">
|
||||||
|
<li><p>pool_name (str) – Name of connection pool</p></li>
|
||||||
|
<li><p>pool_size (int)=5 – Size of pool. If not specified default value of 5 will be used. Maximum allowed number is 64.</p></li>
|
||||||
|
<li><p>pool_reset_connection (bool)=True – Will reset the connection before returning it to the pool. Default value is True.</p></li>
|
||||||
|
</ul>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</dd></dl>
|
||||||
|
|
||||||
|
<div class="section" id="connection-pool-methods">
|
||||||
|
<h2>Connection pool methods<a class="headerlink" href="#connection-pool-methods" title="Permalink to this headline">¶</a></h2>
|
||||||
<dl class="py method">
|
<dl class="py method">
|
||||||
<dt class="sig sig-object py" id="ConnectionPool.add_connection">
|
<dt class="sig sig-object py" id="mariadb.ConnectionPool.add_connection">
|
||||||
<span class="sig-name descname"><span class="pre">add_connection</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">connection</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#ConnectionPool.add_connection" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">ConnectionPool.</span></span><span class="sig-name descname"><span class="pre">add_connection</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">connection</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mariadb.ConnectionPool.add_connection" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Adds a connection object to the connection pool.</p>
|
<dd><p>Adds a connection object to the connection pool.</p>
|
||||||
<p>In case that pool doesn’t have a free slot or is not configured a PoolError
|
<p>In case that the pool doesn’t have a free slot or is not configured
|
||||||
exception will be raised.</p>
|
a PoolError exception will be raised.</p>
|
||||||
</dd></dl>
|
</dd></dl>
|
||||||
|
|
||||||
<dl class="py method">
|
<dl class="py method">
|
||||||
<dt class="sig sig-object py" id="ConnectionPool.close">
|
<dt class="sig sig-object py" id="mariadb.ConnectionPool.close">
|
||||||
<span class="sig-name descname"><span class="pre">close</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ConnectionPool.close" title="Permalink to this definition">¶</a></dt>
|
<span class="sig-prename descclassname"><span class="pre">ConnectionPool.</span></span><span class="sig-name descname"><span class="pre">close</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mariadb.ConnectionPool.close" title="Permalink to this definition">¶</a></dt>
|
||||||
<dd><p>Closes the pool and all connection inside the pool.</p>
|
<dd><p>Closes connection pool and all connections.</p>
|
||||||
|
</dd></dl>
|
||||||
|
|
||||||
|
<dl class="py method">
|
||||||
|
<dt class="sig sig-object py" id="mariadb.ConnectionPool.get_connection">
|
||||||
|
<span class="sig-prename descclassname"><span class="pre">ConnectionPool.</span></span><span class="sig-name descname"><span class="pre">get_connection</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mariadb.ConnectionPool.get_connection" title="Permalink to this definition">¶</a></dt>
|
||||||
|
<dd><p>Returns a connection from the connection pool or raises a PoolError
|
||||||
|
exception if a connection is not available.</p>
|
||||||
|
</dd></dl>
|
||||||
|
|
||||||
|
<dl class="py method">
|
||||||
|
<dt class="sig sig-object py" id="mariadb.ConnectionPool.set_config">
|
||||||
|
<span class="sig-prename descclassname"><span class="pre">ConnectionPool.</span></span><span class="sig-name descname"><span class="pre">set_config</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#mariadb.ConnectionPool.set_config" title="Permalink to this definition">¶</a></dt>
|
||||||
|
<dd><p>Sets the connection configuration for the connection pool.
|
||||||
|
For valid connection arguments check the mariadb.connect() method.</p>
|
||||||
|
<p>Note: This method doesn’t create connections in the pool.
|
||||||
|
To fill the pool one has to use add_connection() ḿethod.</p>
|
||||||
</dd></dl>
|
</dd></dl>
|
||||||
|
|
||||||
<div class="versionadded">
|
|
||||||
<p><span class="versionmodified added">New in version 1.0.1.</span></p>
|
|
||||||
</div>
|
</div>
|
||||||
<dl class="py method">
|
<div class="section" id="connection-pool-attributes">
|
||||||
<dt class="sig sig-object py" id="ConnectionPool.get_connection">
|
<h2>Connection pool attributes<a class="headerlink" href="#connection-pool-attributes" title="Permalink to this headline">¶</a></h2>
|
||||||
<span class="sig-name descname"><span class="pre">get_connection</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ConnectionPool.get_connection" title="Permalink to this definition">¶</a></dt>
|
<dl class="py attribute">
|
||||||
<dd><p>Returns a connection from the connection pool or raises a PoolError if no
|
<dt class="sig sig-object py" id="mariadb.ConnectionPool.max_size">
|
||||||
connection is available.</p>
|
<span class="sig-prename descclassname"><span class="pre">ConnectionPool.</span></span><span class="sig-name descname"><span class="pre">max_size</span></span><a class="headerlink" href="#mariadb.ConnectionPool.max_size" title="Permalink to this definition">¶</a></dt>
|
||||||
|
<dd><p>Returns the maximum size for connection pools.</p>
|
||||||
|
</dd></dl>
|
||||||
|
|
||||||
|
<dl class="py attribute">
|
||||||
|
<dt class="sig sig-object py" id="mariadb.ConnectionPool.pool_size">
|
||||||
|
<span class="sig-prename descclassname"><span class="pre">ConnectionPool.</span></span><span class="sig-name descname"><span class="pre">pool_size</span></span><a class="headerlink" href="#mariadb.ConnectionPool.pool_size" title="Permalink to this definition">¶</a></dt>
|
||||||
|
<dd><p>Returns the size of the connection pool.</p>
|
||||||
|
</dd></dl>
|
||||||
|
|
||||||
|
<dl class="py attribute">
|
||||||
|
<dt class="sig sig-object py" id="mariadb.ConnectionPool.pool_name">
|
||||||
|
<span class="sig-prename descclassname"><span class="pre">ConnectionPool.</span></span><span class="sig-name descname"><span class="pre">pool_name</span></span><a class="headerlink" href="#mariadb.ConnectionPool.pool_name" title="Permalink to this definition">¶</a></dt>
|
||||||
|
<dd><p>Returns the name of the connection pool.</p>
|
||||||
</dd></dl>
|
</dd></dl>
|
||||||
|
|
||||||
<dl class="py method">
|
|
||||||
<dt class="sig sig-object py" id="ConnectionPool.set_config">
|
|
||||||
<span class="sig-name descname"><span class="pre">set_config</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="pre">\*\*kwargs</span></em><span class="sig-paren">)</span><a class="headerlink" href="#ConnectionPool.set_config" title="Permalink to this definition">¶</a></dt>
|
|
||||||
<dd><p>Sets the connection configuration for the connection pool. For valid connection
|
|
||||||
arguments see <a class="reference internal" href="module.html#mariadb.connect" title="mariadb.connect"><code class="xref py py-func docutils literal notranslate"><span class="pre">mariadb.connect()</span></code></a> method.</p>
|
|
||||||
<div class="admonition note">
|
|
||||||
<p class="admonition-title">Note</p>
|
|
||||||
<p>This method doesn’t create connections in the pool. To fill the pool one has to use
|
|
||||||
the <a class="reference internal" href="#ConnectionPool.add_connection" title="ConnectionPool.add_connection"><code class="xref py py-func docutils literal notranslate"><span class="pre">add_connection()</span></code></a> ḿethod.</p>
|
|
||||||
</div>
|
</div>
|
||||||
</dd></dl>
|
|
||||||
|
|
||||||
<dl class="py data">
|
|
||||||
<dt class="sig sig-object py" id="ConnectionPool.max_size">
|
|
||||||
<span class="sig-name descname"><span class="pre">max_size</span></span><a class="headerlink" href="#ConnectionPool.max_size" title="Permalink to this definition">¶</a></dt>
|
|
||||||
<dd><p>Returns the maximum allowed size of the pool</p>
|
|
||||||
</dd></dl>
|
|
||||||
|
|
||||||
<dl class="py data">
|
|
||||||
<dt class="sig sig-object py" id="ConnectionPool.pool_size">
|
|
||||||
<span class="sig-name descname"><span class="pre">pool_size</span></span><a class="headerlink" href="#ConnectionPool.pool_size" title="Permalink to this definition">¶</a></dt>
|
|
||||||
<dd><p>Returns the size of connection pool</p>
|
|
||||||
</dd></dl>
|
|
||||||
|
|
||||||
<dl class="py data">
|
|
||||||
<dt class="sig sig-object py" id="ConnectionPool.pool_name">
|
|
||||||
<span class="sig-name descname"><span class="pre">pool_name</span></span><a class="headerlink" href="#ConnectionPool.pool_name" title="Permalink to this definition">¶</a></dt>
|
|
||||||
<dd><p>Returns the name of the pool.</p>
|
|
||||||
</dd></dl>
|
|
||||||
|
|
||||||
</dd></dl>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -119,6 +130,15 @@ the <a class="reference internal" href="#ConnectionPool.add_connection" title="C
|
|||||||
</div>
|
</div>
|
||||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||||
<div class="sphinxsidebarwrapper">
|
<div class="sphinxsidebarwrapper">
|
||||||
|
<h3><a href="index.html">Table of Contents</a></h3>
|
||||||
|
<ul>
|
||||||
|
<li><a class="reference internal" href="#">The ConnectionPool class</a><ul>
|
||||||
|
<li><a class="reference internal" href="#connection-pool-methods">Connection pool methods</a></li>
|
||||||
|
<li><a class="reference internal" href="#connection-pool-attributes">Connection pool attributes</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<h4>Previous topic</h4>
|
<h4>Previous topic</h4>
|
||||||
<p class="topless"><a href="cursor.html"
|
<p class="topless"><a href="cursor.html"
|
||||||
title="previous chapter">The cursor class</a></p>
|
title="previous chapter">The cursor class</a></p>
|
||||||
|
File diff suppressed because one or more lines are too long
@ -24,7 +24,7 @@ MAX_POOL_SIZE = 64
|
|||||||
POOL_IDLE_TIMEOUT = 1800
|
POOL_IDLE_TIMEOUT = 1800
|
||||||
|
|
||||||
class ConnectionPool(object):
|
class ConnectionPool(object):
|
||||||
"""
|
r"""
|
||||||
Class defining a pool of database connections
|
Class defining a pool of database connections
|
||||||
|
|
||||||
MariaDB Connector/Python supports simple connection pooling.
|
MariaDB Connector/Python supports simple connection pooling.
|
||||||
@ -34,8 +34,15 @@ class ConnectionPool(object):
|
|||||||
The size of a connection pool is configurable at creation time,
|
The size of a connection pool is configurable at creation time,
|
||||||
but cannot be changed afterwards. The maximum size of a connection
|
but cannot be changed afterwards. The maximum size of a connection
|
||||||
pool is limited to 64 connections.
|
pool is limited to 64 connections.
|
||||||
"""
|
|
||||||
|
|
||||||
|
:Keyword Arguments:
|
||||||
|
|
||||||
|
* pool_name (str) -- Name of connection pool
|
||||||
|
|
||||||
|
* pool_size (int)=5 -- Size of pool. If not specified default value of 5 will be used. Maximum allowed number is 64.
|
||||||
|
|
||||||
|
* pool_reset_connection (bool)=True -- Will reset the connection before returning it to the pool. Default value is True.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
@ -182,9 +189,6 @@ class ConnectionPool(object):
|
|||||||
|
|
||||||
def set_config(self, **kwargs):
|
def set_config(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
:param dict configuration
|
|
||||||
configuration settings for pooled connection
|
|
||||||
|
|
||||||
Sets the connection configuration for the connection pool.
|
Sets the connection configuration for the connection pool.
|
||||||
For valid connection arguments check the mariadb.connect() method.
|
For valid connection arguments check the mariadb.connect() method.
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ class Connection(mariadb._mariadb.connection):
|
|||||||
self._execute_command("BEGIN")
|
self._execute_command("BEGIN")
|
||||||
self._read_response()
|
self._read_response()
|
||||||
|
|
||||||
def select_db(self, new_db):
|
def select_db(self, new_db: str):
|
||||||
"""
|
"""
|
||||||
Gets the default database for the current connection.
|
Gets the default database for the current connection.
|
||||||
|
|
||||||
@ -210,13 +210,15 @@ class Connection(mariadb._mariadb.connection):
|
|||||||
|
|
||||||
class xid(tuple):
|
class xid(tuple):
|
||||||
"""
|
"""
|
||||||
|
xid(format_id, global_transaction_id, branch_qualifier)
|
||||||
|
|
||||||
A transaction ID object suitable for passing to the .tpc_*()
|
A transaction ID object suitable for passing to the .tpc_*()
|
||||||
methods of this connection.
|
methods of this connection.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
- format_id: Format id. If not set default value `0` will be used.
|
:param int format_id: Format id. If not set default value `0` will be used.
|
||||||
- global_transaction_id: Global transaction qualifier, which must be unique. The maximum length of the global transaction id is limited to 64 characters.
|
:param str global_transaction_id: Global transaction qualifier, which must be unique. The maximum length of the global transaction id is limited to 64 characters.
|
||||||
- branch_qualifier: Branch qualifier which represents a local transaction identifier. The maximum length of the branch qualifier is limited to 64 characters.
|
:param str branch_qualifier: Branch qualifier which represents a local transaction identifier. The maximum length of the branch qualifier is limited to 64 characters.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def __new__(self, format_id, transaction_id, branch_qualifier):
|
def __new__(self, format_id, transaction_id, branch_qualifier):
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
|
|
||||||
import mariadb, collections
|
import mariadb, collections
|
||||||
from numbers import Number
|
from numbers import Number
|
||||||
from mariadb.constants import *
|
from mariadb.constants import *
|
||||||
|
from typing import Sequence
|
||||||
|
|
||||||
PARAMSTYLE_QMARK= 1
|
PARAMSTYLE_QMARK= 1
|
||||||
PARAMSTYLE_FORMAT= 2
|
PARAMSTYLE_FORMAT= 2
|
||||||
@ -146,19 +147,23 @@ class Cursor(mariadb._mariadb.cursor):
|
|||||||
" doesn't match the number of data elements (%s)."\
|
" doesn't match the number of data elements (%s)."\
|
||||||
% (len(self._paramlist), len(self._data)))
|
% (len(self._paramlist), len(self._data)))
|
||||||
|
|
||||||
def callproc(self, sp: str, data=()):
|
def callproc(self, sp: str, data: Sequence =()):
|
||||||
"""
|
"""
|
||||||
Executes a stored procedure sp. The data sequence must contain an entry for
|
Executes a stored procedure sp. The data sequence must contain an entry for
|
||||||
each parameter the procedure expects.
|
each parameter the procedure expects.
|
||||||
|
|
||||||
Input/Output or Output parameters have to be retrieved by .fetch methods,
|
Input/Output or Output parameters have to be retrieved by .fetch methods,
|
||||||
the .sp_outparams attribute indicates if the result set contains output"
|
the .sp_outparams attribute indicates if the result set contains output
|
||||||
parameters
|
parameters.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
sp: Name of stored procedure.
|
||||||
|
data: Optional sequence containing data for placeholder substitution.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# create statement
|
# create statement
|
||||||
params= ""
|
params= ""
|
||||||
if len(data):
|
if data and len(data):
|
||||||
params= ("?," * len(data))[:-1]
|
params= ("?," * len(data))[:-1]
|
||||||
statement= "CALL %s(%s)" % (sp, params)
|
statement= "CALL %s(%s)" % (sp, params)
|
||||||
self._rowcount= 0
|
self._rowcount= 0
|
||||||
@ -200,7 +205,7 @@ class Cursor(mariadb._mariadb.cursor):
|
|||||||
|
|
||||||
return super()._nextset()
|
return super()._nextset()
|
||||||
|
|
||||||
def execute(self, statement: str, data=(), buffered=False):
|
def execute(self, statement: str, data: Sequence =(), buffered=False):
|
||||||
"""
|
"""
|
||||||
Prepare and execute a SQL statement.
|
Prepare and execute a SQL statement.
|
||||||
|
|
||||||
@ -376,7 +381,7 @@ class Cursor(mariadb._mariadb.cursor):
|
|||||||
ret= row
|
ret= row
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def fetchmany(self, size=0):
|
def fetchmany(self, size: int =0):
|
||||||
"""
|
"""
|
||||||
Fetch the next set of rows of a query result, returning a sequence
|
Fetch the next set of rows of a query result, returning a sequence
|
||||||
of sequences (e.g. a list of tuples). An empty sequence is returned
|
of sequences (e.g. a list of tuples). An empty sequence is returned
|
||||||
@ -416,7 +421,7 @@ class Cursor(mariadb._mariadb.cursor):
|
|||||||
rows.append((row))
|
rows.append((row))
|
||||||
return rows
|
return rows
|
||||||
|
|
||||||
def scroll(self, value, mode="relative"):
|
def scroll(self, value: int, mode="relative"):
|
||||||
"""
|
"""
|
||||||
Scroll the cursor in the result set to a new position according to mode.
|
Scroll the cursor in the result set to a new position according to mode.
|
||||||
|
|
||||||
@ -451,14 +456,14 @@ class Cursor(mariadb._mariadb.cursor):
|
|||||||
self._seek(new_pos);
|
self._seek(new_pos);
|
||||||
self._rownumber= new_pos;
|
self._rownumber= new_pos;
|
||||||
|
|
||||||
def setinputsizes(self, size):
|
def setinputsizes(self, size: int):
|
||||||
"""
|
"""
|
||||||
Required by PEP-249. Does nothing in MariaDB Connector/Python
|
Required by PEP-249. Does nothing in MariaDB Connector/Python
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def setoutputsize(self, size):
|
def setoutputsize(self, size: int):
|
||||||
"""
|
"""
|
||||||
Required by PEP-249. Does nothing in MariaDB Connector/Python
|
Required by PEP-249. Does nothing in MariaDB Connector/Python
|
||||||
"""
|
"""
|
||||||
|
@ -1,60 +0,0 @@
|
|||||||
#
|
|
||||||
# Copyright (C) 2021 Georg Richter and MariaDB Corporation AB
|
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
|
||||||
# modify it under the terms of the GNU Library General Public
|
|
||||||
# License as published by the Free Software Foundation; either
|
|
||||||
# version 2 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
# This library is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
# Library General Public License for more details.
|
|
||||||
|
|
||||||
# You should have received a copy of the GNU Library General Public
|
|
||||||
# License along with this library; if not see <http://www.gnu.org/licenses>
|
|
||||||
# or write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin St., Fifth Floor, Boston, MA 02110, USA
|
|
||||||
#
|
|
||||||
|
|
||||||
import struct
|
|
||||||
|
|
||||||
PROT_CMD_SLEEP= 0
|
|
||||||
PROT_CMD_QUIT= 1
|
|
||||||
PROT_CMD_INIT_DB= 2
|
|
||||||
PROT_CMD_QUERY= 3
|
|
||||||
PROT_CMD_FIELD_LIST= 4
|
|
||||||
PROT_CMD_CREATE_DB= 5
|
|
||||||
PROT_CMD_DROP_DB= 6
|
|
||||||
PROT_CMD_REFRESH= 7
|
|
||||||
PROT_CMD_SHUTDOWN= 8
|
|
||||||
PROT_CMD_STATISTICS= 9
|
|
||||||
PROT_CMD_PROCESS_INFO= 10
|
|
||||||
PROT_CMD_CONNECT= 11
|
|
||||||
PROT_CMD_PROCESS_KILL= 12
|
|
||||||
PROT_CMD_DEBUG= 13
|
|
||||||
PROT_CMD_PING= 14
|
|
||||||
PROT_CMD_TIME= 15,
|
|
||||||
PROT_CMD_DELAYED_INSERT= 16
|
|
||||||
PROT_CMD_CHANGE_USER= 17
|
|
||||||
PROT_CMD_BINLOG_DUMP= 18
|
|
||||||
PROT_CMD_TABLE_DUMP= 19
|
|
||||||
PROT_CMD_CONNECT_OUT = 20
|
|
||||||
PROT_CMD_REGISTER_SLAVE= 21
|
|
||||||
PROT_CMD_STMT_PREPARE= 22
|
|
||||||
PROT_CMD_STMT_EXECUTE= 23
|
|
||||||
PROT_CMD_STMT_SEND_LONG_DATA = 24
|
|
||||||
PROT_CMD_STMT_CLOSE= 25
|
|
||||||
PROT_CMD_STMT_RESET= 26
|
|
||||||
PROT_CMD_SET_OPTION= 27
|
|
||||||
PROT_CMD_STMT_FETCH= 28
|
|
||||||
PROT_CMD_DAEMON= 29
|
|
||||||
PROT_CMD_UNSUPPORTED= 30
|
|
||||||
PROT_CMD_RESET_CONNECTION= 31
|
|
||||||
PROT_CMD_STMT_BULK_EXECUTE= 250
|
|
||||||
|
|
||||||
def prot_length(buffer_size):
|
|
||||||
|
|
||||||
def send_command(socket, command, buffer):
|
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user