mirror of
https://github.com/mariadb-corporation/mariadb-connector-python.git
synced 2025-08-20 16:36:15 +00:00
[misc] doc generation correction
This commit is contained in:
28
.github/workflows/release.yml
vendored
28
.github/workflows/release.yml
vendored
@ -1,9 +1,11 @@
|
||||
name: Generate and Update API Docs
|
||||
|
||||
on:
|
||||
workflow_dispatch: # Allow manual triggering
|
||||
workflow_dispatch:
|
||||
branches: [1.1]
|
||||
release:
|
||||
types: [published] # Runs when release is published
|
||||
types: [published]
|
||||
branches: [1.1]
|
||||
|
||||
jobs:
|
||||
update-docs:
|
||||
@ -102,10 +104,24 @@ jobs:
|
||||
run: |
|
||||
# Remove existing documentation in target subdirectory
|
||||
|
||||
mkdir -p mariadb-docs/connectors/mariadb-connector-python/api/
|
||||
rm -rf mariadb-docs/connectors/mariadb-connector-python/api/*
|
||||
rm -f mariadb-docs/connectors/mariadb-connector-python/api.md
|
||||
rm -f mariadb-docs/connectors/mariadb-connector-python/bugs.md
|
||||
rm -f mariadb-docs/connectors/mariadb-connector-python/connection.md
|
||||
rm -f mariadb-docs/connectors/mariadb-connector-python/constants.md
|
||||
rm -f mariadb-docs/connectors/mariadb-connector-python/cursor.md
|
||||
rm -f mariadb-docs/connectors/mariadb-connector-python/faq.md
|
||||
rm -f mariadb-docs/connectors/mariadb-connector-python/install.md
|
||||
rm -f mariadb-docs/connectors/mariadb-connector-python/license.md
|
||||
rm -f mariadb-docs/connectors/mariadb-connector-python/module.md
|
||||
rm -f mariadb-docs/connectors/mariadb-connector-python/pool.md
|
||||
rm -f mariadb-docs/connectors/mariadb-connector-python/pooling.md
|
||||
rm -f mariadb-docs/connectors/mariadb-connector-python/index.md
|
||||
rm -f mariadb-docs/connectors/mariadb-connector-python/usage.md
|
||||
rm -f mariadb-docs/connectors/mariadb-connector-python/release.md
|
||||
|
||||
# Copy new documentation
|
||||
cp -r docs/_build/markdown/* mariadb-docs/connectors/mariadb-connector-python/api/
|
||||
cp -r docs/_build/markdown/* mariadb-docs/connectors/mariadb-connector-python/
|
||||
mv -f mariadb-docs/connectors/mariadb-connector-python/index.md mariadb-docs/connectors/mariadb-connector-python/README.md
|
||||
|
||||
# Optional: Add any additional processing here
|
||||
# e.g., update index files, fix relative links, etc.
|
||||
@ -116,7 +132,7 @@ jobs:
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git checkout -b auto-docs-update-${{ github.run_number }}
|
||||
git add connectors/mariadb-connector-python/api/
|
||||
git add connectors/mariadb-connector-python/
|
||||
git commit -m "Update API documentation from ${{ github.repository }}"
|
||||
git push https://x-access-token:${{ secrets.SPHINX_TOKEN }}@github.com/rusher/mariadb-docs.git auto-docs-update-${{ github.run_number }}
|
||||
|
||||
|
309
CHANGELOG.md
Normal file
309
CHANGELOG.md
Normal file
@ -0,0 +1,309 @@
|
||||
# Release history
|
||||
|
||||
## MariaDB Connector/Python 1.1.12
|
||||
|
||||
Release date: Feb 24 2025
|
||||
|
||||
**Notable changes:**
|
||||
- [CONPY-299](https://jira.mariadb.org/browse/CONPY-299): Added support for VECTOR: Vectors can be directly used in parameters as float arrays without using tobytes() method or SQL Function Vec_FromText()
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- [CONPY-295](https://jira.mariadb.org/browse/CONPY-295): Fix unsigned check when using executemany() method
|
||||
- [CONPY-300](https://jira.mariadb.org/browse/CONPY-300): Documentation fix (ConnectionPool)
|
||||
- [CONPY-302](https://jira.mariadb.org/browse/CONPY-302): Fix segfault when using threads()
|
||||
- Fixed exception type for ER_BAD_FIELD_ERROR (now OperationalError instead of ProgrammingError)
|
||||
|
||||
## MariaDB Connector/Python 1.1.11
|
||||
|
||||
Release date: Nov 14 2024
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- [CONPY-283](https://jira.mariadb.org/browse/CONPY-283): Incorrect result format after cursor.scroll()
|
||||
- [CONPY-289](https://jira.mariadb.org/browse/CONPY-289): BIGINT out of range on bulk insert
|
||||
- [CONPY-293](https://jira.mariadb.org/browse/CONPY-293): Fix gcc warnings
|
||||
|
||||
**Notable changes:**
|
||||
- Added new connection attribute tls_peer_cert_info
|
||||
- Added support for MariaDB Connector/C 3.4
|
||||
|
||||
## MariaDB Connector/Python 1.1.10
|
||||
|
||||
Release date: Feb 07 2024
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- [CONPY-273](https://jira.mariadb.org/browse/CONPY-273): cursor.execute fails when running in sql_mode ANSI_QUOTES.
|
||||
- [CONPY-278](https://jira.mariadb.org/browse/CONPY-278): Return updated connection_id in case of automatic reconnect
|
||||
- [CONPY-279](https://jira.mariadb.org/browse/CONPY-279): Allow None values for password and database in change_user() method
|
||||
- [CONPY-281](https://jira.mariadb.org/browse/CONPY-281): Use METH_O calling conventions for c functions which accept only one parameter
|
||||
|
||||
## MariaDB Connector/Python 1.1.9
|
||||
|
||||
Release date: Dec 22 2023
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- [CONPY-273](https://jira.mariadb.org/browse/CONPY-273): Fixed crash in escape_string method (debug)
|
||||
- [CONPY-274](https://jira.mariadb.org/browse/CONPY-274): Instead of releasing non freed objects (cursor and connection) in tp_dealloc, they are freed now in tp_finalize to avoid possible crashes
|
||||
- [CONPY-276](https://jira.mariadb.org/browse/CONPY-276): Allow to retrieve data from buffered cursor if the connection was already closed before
|
||||
|
||||
## MariaDB Connector/Python 1.1.8
|
||||
|
||||
Release date: Oct 12 2023
|
||||
|
||||
**Notable changes:**
|
||||
|
||||
- [CONPY-271](https://jira.mariadb.org/browse/CONPY-271): Cusor object provides now a metadata attribute, which returns resultset metadata as a dictionary. metadata attribute also contains information about extended field types like JSON, UUID, INET4/6 and geometry types.
|
||||
- Added new constants mariadb.constants.EXT_FIELD_TYPE which describe extended field types.
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- [CONPY-270](https://jira.mariadb.org/browse/CONPY-270): Data will be converted to Binary only if the character set is binary, the BINARY_FLAG will be ignored.
|
||||
- [CONPY-269](https://jira.mariadb.org/browse/CONPY-269): If cursors rowcount attribute will be retrieved after the cursor was closed, rowcount now returns -1 instead of raising an exception. This is a workaround for a pandas bug.
|
||||
|
||||
## MariaDB Connector/Python 1.1.7
|
||||
|
||||
Release date: Jul 5 2023
|
||||
|
||||
**Notable changes:**
|
||||
|
||||
- [CONPY-253](https://jira.mariadb.org/browse/CONPY-253): The connection method now offers the option of specifying the version of the TLS protocol using tls_version.
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- [CONPY-258](https://jira.mariadb.org/browse/CONPY-258): Fixed ValueError exception if ZEROFILL flag is defined.
|
||||
- [CONPY-256](https://jira.mariadb.org/browse/CONPY-256): Fix indexing when moving a free connection to used connections to avoid returning the same connection twice. Kudos and thanks to G.Mech for reporting this bug and providing the fix.
|
||||
- [CONPY-255](https://jira.mariadb.org/browse/CONPY-255): If all connections from a pool are in use, pool.get_connection now returns None instead of raising an exception.
|
||||
|
||||
## MariaDB Connector/Python 1.1.6
|
||||
|
||||
Release date: Feb 20 2023
|
||||
|
||||
**Notable changes:**
|
||||
|
||||
- [CONPY-247](https://jira.mariadb.org/browse/CONPY-247): Added optional parameter “pool_invalidation_interval”, which specifies the validation interval in milliseconds after which the status of a connection requested from the pool is checked. The default values is 500 milliseconds, a value of 0 means that the status will always be checked.
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- [CONPY-251](https://jira.mariadb.org/browse/CONPY-251): Check if stmt was already initialized in cursor nextset() method.
|
||||
- [CONPY-250](https://jira.mariadb.org/browse/CONPY-250): Fixed calculation of connection pool size
|
||||
- [CONPY-248](https://jira.mariadb.org/browse/CONPY-248): Replace broken connections in connection pool
|
||||
- [CONPY-246](https://jira.mariadb.org/browse/CONPY-246): Rollback transaction if connection pool was created without pool_reset_connection option.
|
||||
- [CONPY-245](https://jira.mariadb.org/browse/CONPY-245): Implementation of LRU cache in connection pool.
|
||||
- [CONPY-240](https://jira.mariadb.org/browse/CONPY-240): Don’t overwrite errormessage/stacktrace if an exception was generated during module initialization.
|
||||
|
||||
## MariaDB Connector/Python 1.1.5
|
||||
|
||||
Release date: Nov 7 2022
|
||||
|
||||
**Notable changes:**
|
||||
|
||||
- Since Connector/C 3.2 is discontinued, minimum required version for MariaDB Connector/Python 1.1.5 is Connector/C 3.3.1
|
||||
- [CONPY-220](https://jira.mariadb.org/browse/CONPY-220): Added \_get_socket() method
|
||||
- Performance improvement: Instead of iterating via fetchone(), fetchall() and fetchmany() methods now load the data directly at once.
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- [CONPY-222](https://jira.mariadb.org/browse/CONPY-222): Removed del() method from cursor
|
||||
- [CONPY-224](https://jira.mariadb.org/browse/CONPY-224): Fixed bulk_operation when reexecuted using same cursor
|
||||
- [CONPY-225](https://jira.mariadb.org/browse/CONPY-225): Fixed cursor.affected_rows property
|
||||
- [CONPY-226](https://jira.mariadb.org/browse/CONPY-226): Replaced deprecated distutils (PEP-632)
|
||||
- [CONPY-227](https://jira.mariadb.org/browse/CONPY-227): Replaced collections.named_tuple by PyStruct_Sequence (C-Python)
|
||||
- .conpy:228: Fixed Installation error (if C/C version < 3.2.4 was found)
|
||||
- .conpy:229: Converter: added missing support for None conversions
|
||||
- .conpy:231: Fixed memory leak
|
||||
|
||||
## MariaDB Connector/Python 1.1.4
|
||||
|
||||
Release date: Aug 10 2022
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- [CONPY-217](https://jira.mariadb.org/browse/CONPY-217): Added reconnect keyword for connection
|
||||
- Added CAPABILITY constants
|
||||
- Code styling fixes (flake8)
|
||||
- [CONPY-218](https://jira.mariadb.org/browse/CONPY-218): Allow None as data parameter in cursor->execute(). Kudos to Luciano Barcaro for providing a fix
|
||||
- [CONPY-214](https://jira.mariadb.org/browse/CONPY-214): Replaced cursor iterator by native Python iter() method.
|
||||
|
||||
## MariaDB Connector/Python 1.1.3
|
||||
|
||||
Release date: Jul 07 2022
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
> - [CONPY-209](https://jira.mariadb.org/browse/CONPY-209): Wrong unicode substitution in SELECT statement
|
||||
> - [CONPY-210](https://jira.mariadb.org/browse/CONPY-210): Added missing error constants
|
||||
> - [CONPY-212](https://jira.mariadb.org/browse/CONPY-212): unbuffered cursor.execute() doesn’t work
|
||||
|
||||
## MariaDB Connector/Python 1.1.2
|
||||
|
||||
Release date: Jun 27 2022
|
||||
|
||||
**Notable changes:**
|
||||
|
||||
> - [CONPY-203](https://jira.mariadb.org/browse/CONPY-203): Error constants added
|
||||
> - [CONPY-204](https://jira.mariadb.org/browse/CONPY-204): New connection method dump_debug_info(
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
> Removed utf8 part of internal parser and use binary objects for parameter substitution
|
||||
> - [CONPY-205](https://jira.mariadb.org/browse/CONPY-205): Fixed inconsistent exceptions: All parameter exceptions are returned as ProgrammingError.
|
||||
> Fixed memory leak when using decimal parameters
|
||||
> - [CONPY-201](https://jira.mariadb.org/browse/CONPY-201): Fixed build issues with Python 3.11 beta
|
||||
|
||||
## MariaDB Connector/Python 1.0.11
|
||||
|
||||
Release date: Apr 12 2022
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
> - [CONPY-194](https://jira.mariadb.org/browse/CONPY-194): executemany() does not work with returning clause
|
||||
> - [CONPY-196](https://jira.mariadb.org/browse/CONPY-196): Missing decrement of reference pointer when closing cursor
|
||||
> - [CONPY-198](https://jira.mariadb.org/browse/CONPY-198): Build fix for FreeBSD
|
||||
|
||||
## MariaDB Connector/Pyhon 1.0.10
|
||||
|
||||
Release date: Feb 18 2022
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- - [CONPY-184](https://jira.mariadb.org/browse/CONPY-184): Display status of connection, cursor and pool class in string representation.
|
||||
- - [CONPY-178](https://jira.mariadb.org/browse/CONPY-178): Repeated execution of cursors callproc() method hangs
|
||||
- - [CONPY-175](https://jira.mariadb.org/browse/CONPY-175): Fixed crash in escape_string
|
||||
|
||||
## MariaDB Connector/Python 1.0.9
|
||||
|
||||
Release date: Dec 21 2021
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- [CONPY-184](https://jira.mariadb.org/browse/CONPY-184): Display status of connection, cursor and pool class in string representation.
|
||||
- [CONPY-178](https://jira.mariadb.org/browse/CONPY-178): Repeated execution of cursors callproc() method hangs
|
||||
- [CONPY-175](https://jira.mariadb.org/browse/CONPY-175): Fixed crash in escape_string
|
||||
|
||||
## MariaDB Connector/Python 1.0.8
|
||||
|
||||
Release date: Oct 22 2021
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- [CONPY-173](https://jira.mariadb.org/browse/CONPY-173): Fixed windows build for Python 3.10
|
||||
|
||||
## MariaDB Connector/Python 1.0.7
|
||||
|
||||
Release date: Jun 8 2021
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- [CONPY-155](https://jira.mariadb.org/browse/CONPY-155): fixed crash in get_server_version method of connection class
|
||||
- [CONPY-144](https://jira.mariadb.org/browse/CONPY-144): fixed crash in connection pool
|
||||
- [CONPY-150](https://jira.mariadb.org/browse/CONPY-150): convert invalid date types (day, month or year=0) to NULL
|
||||
|
||||
## MariaDB Connector/Python 1.0.6
|
||||
|
||||
Release date: Feb 24 2021
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- [CONPY-142](https://jira.mariadb.org/browse/CONPY-142): Fixed memory leak in connection class (server_version_info)
|
||||
- [CONPY-138](https://jira.mariadb.org/browse/CONPY-138), [CONPY-141](https://jira.mariadb.org/browse/CONPY-141): When using binary protocol, convert data to binary object only if the character set is BINARY (63), not if the flag was set and character set is a non binary character set.
|
||||
- Various build and travis related corrections/fixes.
|
||||
|
||||
## MariaDB Connector/Python 1.0.5
|
||||
|
||||
Release date: Nov 25th 2020
|
||||
|
||||
**Notable changes:**
|
||||
|
||||
- [CONPY-127](https://jira.mariadb.org/browse/CONPY-127): When establishing a new database connection the connect method now also supports None values instead of strings only.
|
||||
- [CONPY-128](https://jira.mariadb.org/browse/CONPY-128): Added connection attribute server_version_info and (for compatibility) get_server_version() method. Both return a tuple, describing the version number of connected server in following format: (MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION)
|
||||
- [CONPY-133](https://jira.mariadb.org/browse/CONPY-133): The internal parser now supports the full MariaDB comment syntax
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- [CONPY-126](https://jira.mariadb.org/browse/CONPY-126): Fixed memory leak in connection object
|
||||
- [CONPY-130](https://jira.mariadb.org/browse/CONPY-130): Fixed DeprecationWarning: builtin type Row has no module attribute
|
||||
- [CONPY-131](https://jira.mariadb.org/browse/CONPY-131): Fixed crash type_traverse() called for non-heap type Row (Python 3.6 only)
|
||||
- [CONPY-132](https://jira.mariadb.org/browse/CONPY-132): Fixed memory leak in connection pool
|
||||
|
||||
## MariaDB Connector/Python 1.0.4
|
||||
|
||||
Release date: Oct 20th 2020
|
||||
|
||||
**Notable changes:**
|
||||
|
||||
Binary wheel packages are now availble for Windows on [http://pypi.org](http://pypi.org)
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- [CONPY-123](https://jira.mariadb.org/browse/CONPY-123): Free pending result sets when closing cursor
|
||||
- [CONPY-124](https://jira.mariadb.org/browse/CONPY-124): Fix build when building against Connector/C < 3.1.8
|
||||
- [CONPY-125](https://jira.mariadb.org/browse/CONPY-125): Build fix: replace obsolete ULONG_LONG_MAX definitions
|
||||
|
||||
## MariaDB Connector/Python 1.0.3
|
||||
|
||||
Release date: Oct 7th 2020
|
||||
|
||||
**Notable changes:**
|
||||
|
||||
- [CONPY-117](https://jira.mariadb.org/browse/CONPY-117): Added support for data type conversion.
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- [CONPY-116](https://jira.mariadb.org/browse/CONPY-116): Wrong type reporting for column type MYSQL_TYPE_JSON
|
||||
- [CONPY-118](https://jira.mariadb.org/browse/CONPY-118): Removed statement allocation for text protocol
|
||||
- [CONPY-119](https://jira.mariadb.org/browse/CONPY-119): Fixed memory leak when cursor result is dictionary
|
||||
|
||||
## MariaDB Connector/Python 1.0.2
|
||||
|
||||
Release date: Sept 18th 2020
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- Fixed datetime initialization
|
||||
- [CONPY-108](https://jira.mariadb.org/browse/CONPY-108): Fixed memory leak
|
||||
- [CONPY-110](https://jira.mariadb.org/browse/CONPY-110): Fixed memory overrun when passing ssl keyword to connect() method.
|
||||
|
||||
## MariaDB Connector/Python 1.0.1
|
||||
|
||||
Release date: August 18th 2020
|
||||
|
||||
**Notable changes:**
|
||||
|
||||
- [CONPY-100](https://jira.mariadb.org/browse/CONPY-100): added binary option for cursor which allows to use binary protocol without passing parameters
|
||||
- [CONPY-102](https://jira.mariadb.org/browse/CONPY-102): Default for autocommit is now off
|
||||
- [CONPY-105](https://jira.mariadb.org/browse/CONPY-105): Behavior of rowcount and lastrowid atttributes now conforms to PEP-249
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- [CONPY-82](https://jira.mariadb.org/browse/CONPY-82): Unlock mutex in case of ConnectionPool.add_connection failed
|
||||
- [CONPY-83](https://jira.mariadb.org/browse/CONPY-83): Fixed missing reference increment in ConnectionPool class
|
||||
- [CONPY-85](https://jira.mariadb.org/browse/CONPY-85): Fixed version checking in setup.py
|
||||
- [CONPY-93](https://jira.mariadb.org/browse/CONPY-93): Release GIL before calling Python’s memory allocation routine
|
||||
- [CONPY-94](https://jira.mariadb.org/browse/CONPY-94): Support python subclasses for data binding
|
||||
- [CONPY-95](https://jira.mariadb.org/browse/CONPY-95): Added support for MYSQL_TYPE_BIT column type
|
||||
- [CONPY-98](https://jira.mariadb.org/browse/CONPY-98): Return binary object when casting to binary
|
||||
- [CONPY-99](https://jira.mariadb.org/browse/CONPY-99): Fixed memory leak in fetchall() method.
|
||||
- [CONPY-101](https://jira.mariadb.org/browse/CONPY-101): Fixed negative reference count when using callproc() method.
|
||||
- [CONPY-106](https://jira.mariadb.org/browse/CONPY-106): exception handling: type of exception depends now on error code instead of sqlstate
|
||||
- [CONPY-107](https://jira.mariadb.org/browse/CONPY-107): convert negative time values to datetime.timedelta instances
|
||||
|
||||
## MariaDB Connector/Python 1.0.0
|
||||
|
||||
Release date: June 24th 2020
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- [CONPY-69](https://jira.mariadb.org/browse/CONPY-69): Set default character set (utf8mb4) with authentication packet
|
||||
- [CONPY-70](https://jira.mariadb.org/browse/CONPY-70): set_config() method needs to check the passed parameter and raise an exception if the parameter type is not a dictionary.
|
||||
- [CONPY-72](https://jira.mariadb.org/browse/CONPY-72): When deallocating the connection pool class, we need to check beside pool_size if the array containing the connections is valid.
|
||||
- [CONPY-76](https://jira.mariadb.org/browse/CONPY-76): Added aliases username, passwd and db to connection keywords.
|
||||
- [CONPY-78](https://jira.mariadb.org/browse/CONPY-78): Since MaxScale doesn’t support bulk operations yet, we have to check servers extended capability flag to determine if this feature is supported or not.
|
||||
- [CONPY-79](https://jira.mariadb.org/browse/CONPY-79): When inserting NULL values with executemany() method on a server which doesn’t support BULK statements NULL values weren’t inserted correctly.
|
||||
- [CONPY-80](https://jira.mariadb.org/browse/CONPY-80): Parameters in set_config() method of ConnectionPool class have to be checked against the list of DSN keywords
|
||||
- [CONPY-81](https://jira.mariadb.org/browse/CONPY-81): Fixed crash when switching between text and binary protocol with same cursor
|
||||
- Fixed bug when inserting negative integer values with cursor.execute() method
|
||||
|
||||
{% @marketo/form formId="4316" %}
|
@ -14,3 +14,4 @@ API Reference
|
||||
pool
|
||||
constants
|
||||
|
||||
{% @marketo/form formId=\"4316\" %}
|
@ -9,19 +9,19 @@ How to report a bug?
|
||||
|
||||
Search first
|
||||
^^^^^^^^^^^^
|
||||
Always search the bug database first. Especially if you are using an older version of MariaDB Connector/Python it could
|
||||
be reported already by someone else or it was already fixed in a more recent version.
|
||||
Always search the bug database first. Especially if you are using an older version of MariaDB Connector/Python it could be reported already by someone else or it was already fixed in a more recent version.
|
||||
|
||||
What?
|
||||
^^^^^
|
||||
We need to know what you did, what happened and what you wanted to happen. A report stating that method xyz() hangs, will
|
||||
not allow us to provide you with an advice or fix, since we just don't know what the method is doing.
|
||||
Beside versions a good bug report contains a short script which reproduces the problem. Sometimes it is also necessary to
|
||||
We need to know what you did, what happened and what you wanted to happen. A report stating that method xyz() hangs, will not allow us to provide you with an advice or fix, since we just don't know what the method is doing.
|
||||
Beside versions, a good bug report contains a short script which reproduces the problem. Sometimes it is also necessary to
|
||||
provide the definition (and data) of used tables.
|
||||
|
||||
Versions of components
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
MariaDB Connector/Python interacts with two other components: The database server and MariaDB Connector/C. Latter one is responsible for client/server communication. An error does not necessarily have to exist in Connector / Python; it can also be an error in the database server or in Connector/C. In this case we will reclassify the bug (MDEV or CONC).
|
||||
MariaDB Connector/Python interacts with two other components: The database server and MariaDB Connector/C. The latter one is responsible for client/server communication.
|
||||
An error does not necessarily have to exist in Connector / Python; it can also be an error in the database server or in Connector/C.
|
||||
In this case, we will reclassify the bug (MDEV or CONC).
|
||||
|
||||
Avoid screenshots!
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
@ -30,11 +30,9 @@ read on mobile devices. Typing program code from a screenshot is also an unneces
|
||||
|
||||
Keep it simple!
|
||||
^^^^^^^^^^^^^^^
|
||||
Scripts which are longer than 10 lines often contain code which is not relevant to the problem and increases
|
||||
the time to figure out the real problem. So try to keep it simple and focus on the real problem.
|
||||
Scripts which are longer than 10 lines often contain code which is not relevant to the problem and increases the time to figure out the real problem. So try to keep it simple and focus on the real problem.
|
||||
|
||||
The sane applies for database related components like tables, views and stored procedures. Avoid table definitions with
|
||||
hundred of columns if the problem can be reproduced with only 4 columns,
|
||||
The sane applies for database related components like tables, views, and stored procedures. Avoid table definitions with hundreds of columns if the problem can be reproduced with only 4 columns.
|
||||
|
||||
Only report one problem in one bug report
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -46,3 +44,5 @@ If your application crashes, please also provide if possible a backtrace and out
|
||||
|
||||
Report bugs in English only!
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
{% @marketo/form formId=\"4316\" %}
|
@ -10,36 +10,37 @@ The connection class
|
||||
Connection constructors
|
||||
-----------------------
|
||||
|
||||
.. automethod:: mariadb.connections.Connection.cursor
|
||||
|
||||
.. versionadded:: 1.0.1
|
||||
.. automethod:: mariadb.connections.Connection.xid
|
||||
|
||||
*Since version 1.0.1.*
|
||||
|
||||
------------------
|
||||
Connection methods
|
||||
------------------
|
||||
|
||||
.. versionadded:: 1.1.0
|
||||
.. automethod:: mariadb.connections.Connection.begin
|
||||
|
||||
*Since version 1.1.0.*
|
||||
|
||||
.. automethod:: mariadb.connections.Connection.commit
|
||||
|
||||
.. automethod:: mariadb.connections.Connection.change_user(user, password, database)
|
||||
.. automethod:: mariadb.connections.Connection.change_user
|
||||
|
||||
.. automethod:: mariadb.connections.Connection.close
|
||||
|
||||
.. automethod:: mariadb.connections.Connection.cursor
|
||||
|
||||
.. versionadded:: 1.1.2
|
||||
.. automethod:: mariadb.connections.Connection.dump_debug_info
|
||||
|
||||
*Since version 1.1.2.*
|
||||
|
||||
.. automethod:: mariadb.connections.Connection.get_server_version
|
||||
|
||||
.. versionadded:: 1.0.5
|
||||
.. automethod:: mariadb.connections.Connection.escape_string
|
||||
|
||||
.. testcode::
|
||||
*Since version 1.0.5.*
|
||||
|
||||
.. testcode::
|
||||
import mariadb
|
||||
|
||||
# connection parameters
|
||||
@ -49,36 +50,34 @@ Connection methods
|
||||
"host" : "localhost"
|
||||
}
|
||||
|
||||
# Establish a connection
|
||||
connection= mariadb.connect(**conn_params)
|
||||
with mariadb.connect(**conn_params) as connection:
|
||||
string = 'This string contains the following special characters: \\,"'
|
||||
print(connection.escape_string(string))
|
||||
|
||||
string= 'This string contains the following special characters: \,"'
|
||||
print(connection.escape_string(string))
|
||||
|
||||
*Output*:
|
||||
**Output:**
|
||||
|
||||
.. testoutput::
|
||||
|
||||
This string contains the following special characters: \\,\"
|
||||
|
||||
This string contains the following special characters: \\,\"
|
||||
|
||||
.. automethod:: mariadb.connections.Connection.kill
|
||||
|
||||
.. note::
|
||||
A thread_id from other connections can be determined by executing the SQL statement ``SHOW PROCESSLIST``
|
||||
The thread_id of the current connection the current connection is stored in :data:`connection_id` attribute.
|
||||
.. note::
|
||||
A thread_id from other connections can be determined by executing the SQL statement ``SHOW PROCESSLIST``.
|
||||
The thread_id of the current connection is stored in the :data:`connection_id` attribute.
|
||||
|
||||
.. automethod:: mariadb.connections.Connection.ping()
|
||||
.. automethod:: mariadb.connections.Connection.ping
|
||||
|
||||
.. automethod:: mariadb.connections.Connection.reconnect
|
||||
|
||||
.. automethod:: mariadb.connections.Connection.reset
|
||||
|
||||
.. automethod:: mariadb.connections.Connection.rollback()
|
||||
.. automethod:: mariadb.connections.Connection.rollback
|
||||
|
||||
.. versionadded:: 1.1.0
|
||||
.. automethod:: mariadb.connections.Connection.select_db
|
||||
|
||||
*Since version 1.1.0.*
|
||||
|
||||
.. automethod:: mariadb.connections.Connection.show_warnings
|
||||
|
||||
.. automethod:: mariadb.connections.Connection.tpc_begin
|
||||
@ -101,47 +100,56 @@ Connection attributes
|
||||
|
||||
.. autoattribute:: mariadb.connections.Connection.character_set
|
||||
|
||||
.. versionadded:: 1.1.0:
|
||||
.. autoattribute:: mariadb.connections.Connection.client_capabilities
|
||||
|
||||
*Since version 1.1.0.*
|
||||
|
||||
.. autoattribute:: mariadb.connections.Connection.collation
|
||||
|
||||
.. autoattribute:: mariadb.connections.Connection.connection_id
|
||||
|
||||
.. autoattribute:: mariadb.connections.Connection.database
|
||||
|
||||
.. versionadded:: 1.1.0
|
||||
.. autoattribute:: mariadb.connections.Connection.open
|
||||
|
||||
.. versionadded:: 1.1.0
|
||||
*Since version 1.1.0.*
|
||||
|
||||
.. autoattribute:: mariadb.connections.Connection.server_capabilities
|
||||
|
||||
.. versionadded:: 1.1.0
|
||||
*Since version 1.1.0.*
|
||||
|
||||
.. autoattribute:: mariadb.connections.Connection.extended_server_capabilities
|
||||
|
||||
*Since version 1.1.0.*
|
||||
|
||||
.. autoattribute:: mariadb.connections.Connection.server_info
|
||||
|
||||
.. autoattribute:: mariadb.connections.Connection.server_name
|
||||
|
||||
.. autoattribute:: mariadb.connections.Connection.server_port
|
||||
|
||||
.. versionadded:: 1.1.0
|
||||
.. autoattribute:: mariadb.connections.Connection.server_status
|
||||
|
||||
*Since version 1.1.0.*
|
||||
|
||||
.. autoattribute:: mariadb.connections.Connection.server_version
|
||||
|
||||
.. autoattribute:: mariadb.connections.Connection.server_version_info
|
||||
|
||||
.. versionadded:: 1.0.5
|
||||
.. autoattribute:: mariadb.connections.Connection.tls_cipher
|
||||
|
||||
*Since version 1.0.5.*
|
||||
|
||||
.. autoattribute:: mariadb.connections.Connection.tls_version
|
||||
|
||||
.. versionadded:: 1.1.11
|
||||
.. autoattribute:: mariadb.connections.Connection.tls_peer_cert_info
|
||||
|
||||
*Since version 1.1.11.*
|
||||
|
||||
.. autoattribute:: mariadb.connections.Connection.unix_socket
|
||||
|
||||
.. autoattribute:: mariadb.connections.Connection.user
|
||||
|
||||
.. autoattribute:: mariadb.connections.Connection.warnings
|
||||
|
||||
{% @marketo/form formId=\"4316\" %}
|
@ -3,7 +3,7 @@ Constants
|
||||
|
||||
Constants are declared in mariadb.constants module.
|
||||
|
||||
For using constants of various types they have to be imported first:
|
||||
For using constants of various types, they have to be imported first:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@ -13,10 +13,10 @@ Constants
|
||||
CAPABILITY
|
||||
----------
|
||||
|
||||
.. versionadded:: 1.1.4
|
||||
|
||||
.. automodule:: mariadb.constants.CAPABILITY
|
||||
|
||||
*Since version 1.1.4*
|
||||
|
||||
.. testcode::
|
||||
|
||||
import mariadb
|
||||
@ -29,12 +29,10 @@ CAPABILITY
|
||||
"host" : "localhost"
|
||||
}
|
||||
|
||||
# Establish a connection
|
||||
connection= mariadb.connect(**conn_params)
|
||||
|
||||
# test if LOAD DATA LOCAL INFILE is supported
|
||||
if connection.server_capabilities & CAPABILITY.LOCAL_FILES:
|
||||
print("Server supports LOCAL INFILE")
|
||||
with mariadb.connect(**conn_params) as connection:
|
||||
# test if LOAD DATA LOCAL INFILE is supported
|
||||
if connection.server_capabilities & CAPABILITY.LOCAL_FILES:
|
||||
print("Server supports LOCAL INFILE")
|
||||
|
||||
*Output*:
|
||||
|
||||
@ -47,21 +45,18 @@ CAPABILITY
|
||||
CLIENT
|
||||
--------------
|
||||
|
||||
.. versionadded:: 1.1.0
|
||||
|
||||
.. automodule:: mariadb.constants.CLIENT
|
||||
|
||||
.. deprecated:: 1.1.4
|
||||
Use CAPABILITY constants instead
|
||||
*Since version 1.1.0, deprecated in 1.1.4*
|
||||
|
||||
--------------
|
||||
CURSOR
|
||||
--------------
|
||||
|
||||
.. versionadded:: 1.1.0
|
||||
|
||||
.. automodule:: mariadb.constants.CURSOR
|
||||
|
||||
*Since version 1.1.0*
|
||||
|
||||
.. py:data:: CURSOR.NONE
|
||||
|
||||
This is the default setting (no cursor)
|
||||
@ -75,12 +70,11 @@ CURSOR
|
||||
ERR (Error)
|
||||
--------------
|
||||
|
||||
.. versionadded:: 1.1.2
|
||||
|
||||
|
||||
Using ERR constants instead of error numbers make the code more readable. Error constants
|
||||
are defined in constants.ERR module
|
||||
|
||||
*Since version 1.1.2*
|
||||
|
||||
.. testcode::
|
||||
|
||||
import mariadb
|
||||
@ -110,10 +104,10 @@ are defined in constants.ERR module
|
||||
FIELD_FLAG
|
||||
--------------
|
||||
|
||||
.. versionadded:: 1.1.0
|
||||
|
||||
.. automodule:: mariadb.constants.FIELD_FLAG
|
||||
|
||||
*Since version 1.1.0*
|
||||
|
||||
|
||||
.. py:data:: FIELD_FLAG.NOT_NULL
|
||||
|
||||
@ -281,7 +275,7 @@ FIELD_TYPE
|
||||
|
||||
.. py:data:: FIELD_TYPE.STRING
|
||||
|
||||
column tyoe is CHAR (fixed length)
|
||||
column type is CHAR (fixed length)
|
||||
|
||||
.. py:data:: FIELD_TYPE.GEOMETRY
|
||||
|
||||
@ -315,25 +309,21 @@ indicates not to update the entire row.
|
||||
INFO
|
||||
---------------
|
||||
|
||||
.. versionadded:: 1.1.0
|
||||
|
||||
For internal use only
|
||||
|
||||
---------------
|
||||
TPC_STATE
|
||||
---------------
|
||||
|
||||
.. versionadded:: 1.1.0
|
||||
|
||||
For internal use only
|
||||
|
||||
|
||||
---------------
|
||||
STATUS
|
||||
---------------
|
||||
.. versionadded:: 1.1.0
|
||||
The STATUS constants are used to check the server status of the current connection.
|
||||
|
||||
The STATUS constants are used to check the server status of
|
||||
the current connection.
|
||||
*Since version 1.1.0*
|
||||
|
||||
Example:
|
||||
|
||||
@ -403,3 +393,5 @@ the current connection.
|
||||
.. py:data:: STATUS.ANSI_QUOTES
|
||||
|
||||
SQL mode ANSI_QUOTES is active,
|
||||
|
||||
{% @marketo/form formId=\"4316\" %}
|
@ -99,7 +99,8 @@ Cursor attributes
|
||||
In combination with the type element field, it can be determined for example,
|
||||
whether a column is a BLOB or TEXT field:
|
||||
|
||||
.. versionadded:: 1.1.0
|
||||
*Since version 1.1.0*
|
||||
|
||||
The parameter table_name, original_column_name and original_table_name are an
|
||||
extension to the PEP-249 DB API standard.
|
||||
|
||||
@ -114,17 +115,17 @@ Cursor attributes
|
||||
|
||||
.. autoattribute:: mariadb.cursors.Cursor.lastrowid
|
||||
|
||||
.. versionadded:: 1.1.8
|
||||
|
||||
.. autoattribute:: mariadb.cursors.Cursor.metadata
|
||||
|
||||
*Since version 1.1.8*
|
||||
|
||||
.. autoattribute:: mariadb.cursors.Cursor.sp_outparams
|
||||
|
||||
|
||||
.. versionadded:: 1.1.0
|
||||
|
||||
.. autoattribute:: mariadb.cursors.Cursor.paramcount
|
||||
|
||||
*Since version 1.1.0*
|
||||
|
||||
.. autoattribute:: mariadb.cursors.Cursor.rowcount
|
||||
|
||||
.. note::
|
||||
@ -155,3 +156,5 @@ Cursor attributes
|
||||
.. note::
|
||||
|
||||
Warnings can be retrieved by the show_warnings() method of connection class.
|
||||
|
||||
{% @marketo/form formId=\"4316\" %}
|
@ -11,244 +11,257 @@ entries!
|
||||
Installation
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. collapse:: Error: "Python.h: No such file or directory"
|
||||
Error: "Python.h: No such file or directory"
|
||||
--------------------------------------------
|
||||
|
||||
The header files and libraries of the Python development package weren't properly installed.
|
||||
Use your package manager to install them system-wide:
|
||||
The header files and libraries of the Python development package weren't properly installed.
|
||||
Use your package manager to install them system-wide:
|
||||
|
||||
.. collapse:: Alpine (using apk):
|
||||
**Alpine (using apk):**
|
||||
|
||||
.. code-block:: console
|
||||
.. code-block:: console
|
||||
|
||||
sudo apk add python3-dev
|
||||
sudo apk add python3-dev
|
||||
|
||||
.. collapse:: Ubuntu/Debian (using apt):
|
||||
**Ubuntu/Debian (using apt):**
|
||||
|
||||
.. code-block:: console
|
||||
.. code-block:: console
|
||||
|
||||
sudo apt-get install python3-dev
|
||||
sudo apt-get install python3-dev
|
||||
|
||||
.. collapse:: CentOS/RHEL (using yum):
|
||||
**CentOS/RHEL (using yum):**
|
||||
|
||||
.. code-block:: console
|
||||
.. code-block:: console
|
||||
|
||||
sudo yum install python3-devel
|
||||
sudo yum install python3-devel
|
||||
|
||||
.. collapse:: Fedora (using dnf):
|
||||
**Fedora (using dnf):**
|
||||
|
||||
.. code-block:: console
|
||||
.. code-block:: console
|
||||
|
||||
sudo dnf install python3-devel
|
||||
sudo dnf install python3-devel
|
||||
|
||||
.. collapse:: MacOSX (using homebrew)
|
||||
**MacOSX (using homebrew):**
|
||||
|
||||
.. code-block:: console
|
||||
.. code-block:: console
|
||||
|
||||
brew install mariadb-connector-c
|
||||
brew install mariadb-connector-c
|
||||
|
||||
.. collapse:: OpenSuse (using zypper):
|
||||
**OpenSuse (using zypper):**
|
||||
|
||||
.. code-block:: console
|
||||
.. code-block:: console
|
||||
|
||||
sudo zypper in python3-devel
|
||||
sudo zypper in python3-devel
|
||||
|
||||
Note: The python3 development packages of your distribution might not cover all minor versions
|
||||
of python3. If you are using python3.10 you may need install python3.10-dev.
|
||||
Note: The python3 development packages of your distribution might not cover all minor versions
|
||||
of python3. If you are using python3.10 you may need to install python3.10-dev.
|
||||
|
||||
|
||||
.. collapse:: ModuleNotFoundError: No module named 'packaging'
|
||||
ModuleNotFoundError: No module named 'packaging'
|
||||
-------------------------------------------------
|
||||
|
||||
With deprecation of distutils (see :PEP:`632`) version functions of distutils module were
|
||||
replaced in |MCP| 1.1.5 by packaging version functions.
|
||||
With deprecation of distutils (see :PEP:`632`) version functions of distutils module were
|
||||
replaced in |MCP| 1.1.5 by packaging version functions.
|
||||
|
||||
Before you can install |MCP| you have to install the packaging module:
|
||||
Before you can install |MCP| you have to install the packaging module:
|
||||
|
||||
.. code-block:: console
|
||||
.. code-block:: console
|
||||
|
||||
pip3 install packaging
|
||||
pip3 install packaging
|
||||
|
||||
.. collapse:: MariaDB Connector/Python requires MariaDB Connector/C >= 3.3.1, found version 3.1.2
|
||||
MariaDB Connector/Python requires MariaDB Connector/C >= 3.3.1, found version 3.1.2
|
||||
--------------------------------------------------------------------------------------
|
||||
|
||||
The previously installed version of |MCC| is too old and cannot be used for the |MCP| version
|
||||
you are trying to install.
|
||||
The previously installed version of |MCC| is too old and cannot be used for the |MCP| version
|
||||
you are trying to install.
|
||||
|
||||
To determine the installed version of |MCC|, execute the command
|
||||
To determine the installed version of |MCC|, execute the command:
|
||||
|
||||
.. code-block:: console
|
||||
.. code-block:: console
|
||||
|
||||
mariadb_config --cc_version
|
||||
mariadb_config --cc_version
|
||||
|
||||
- Check if your distribution can be upgraded to a more recent version of |MCC|, which fits the requirements.
|
||||
- If your distribution doesn't provide a recent version of |MCC|, check the |MCDP|, which provides
|
||||
latest versions for the major distributions.
|
||||
- If none of the above will work for you, build and install |MCC| from source.
|
||||
- Check if your distribution can be upgraded to a more recent version of |MCC|, which fits the requirements.
|
||||
- If your distribution doesn't provide a recent version of |MCC|, check the |MCDP|, which provides
|
||||
latest versions for the major distributions.
|
||||
- If none of the above will work for you, build and install |MCC| from source.
|
||||
|
||||
.. collapse:: OSError: mariadb_config not found.
|
||||
OSError: mariadb_config not found
|
||||
----------------------------------
|
||||
|
||||
The mariadb_config program is used to retrieve configuration information (such as the location of
|
||||
header files and libraries, installed version, ..) from |MCC|
|
||||
The mariadb_config program is used to retrieve configuration information (such as the location of
|
||||
header files and libraries, installed version, etc.) from |MCC|.
|
||||
|
||||
This error indicates that |MCC|, an important dependency for client/server communication that needs
|
||||
to be preinstalled, either was not installed or could not be found.
|
||||
This error indicates that |MCC|, an important dependency for client/server communication that needs
|
||||
to be preinstalled, either was not installed or could not be found.
|
||||
|
||||
* If |MCC| was previously installed, the installation script cannot detect the location of mariadb_config.
|
||||
Locate the directory where mariadb_config was installed and add this directory to your PATH.
|
||||
* If |MCC| was previously installed, the installation script cannot detect the location of mariadb_config.
|
||||
Locate the directory where mariadb_config was installed and add this directory to your PATH.
|
||||
|
||||
.. code-block:: console
|
||||
.. code-block:: console
|
||||
|
||||
# locate mariadb_config
|
||||
sudo find / -name "mariadb_config"
|
||||
# locate mariadb_config
|
||||
sudo find / -name "mariadb_config"
|
||||
|
||||
* If |MCC| was not installed and the location of mariadb_config couldn't be detected, please install
|
||||
MariaDB Connector/C.
|
||||
* If |MCC| was not installed and the location of mariadb_config couldn't be detected, please install
|
||||
MariaDB Connector/C.
|
||||
|
||||
.. collapse:: Error: struct st_mariadb_methods’ has no member named ‘db_execute_generate_request’
|
||||
Error: struct st_mariadb_methods' has no member named 'db_execute_generate_request'
|
||||
-----------------------------------------------------------------------------------
|
||||
|
||||
Even if the correct version of |MCC| was installed, there are multiple mysql.h include files installed
|
||||
on your system, either from libmysql or an older |MCC| installation. This can be checked by executing
|
||||
Even if the correct version of |MCC| was installed, there are multiple mysql.h include files installed
|
||||
on your system, either from libmysql or an older |MCC| installation. This can be checked by executing:
|
||||
|
||||
.. code-block:: console
|
||||
.. code-block:: console
|
||||
|
||||
export CFLAGS="-V -E"
|
||||
pip3 install mariadb > output.txt
|
||||
export CFLAGS="-V -E"
|
||||
pip3 install mariadb > output.txt
|
||||
|
||||
Open output.txt in your favourite editor and search for "search starts here" where you can see the include
|
||||
files and paths used for the build.
|
||||
Open output.txt in your favourite editor and search for "search starts here" where you can see the include
|
||||
files and paths used for the build.
|
||||
|
||||
.. collapse:: Q: My distribution doesn't provide a recent version of MariaDB Connector/C
|
||||
Q: My distribution doesn't provide a recent version of MariaDB Connector/C
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
If you distribution doesn't provide a recent version of |MCC| (required version is |MCC_minversion| ) you either
|
||||
can download a version of |MCC| from the |MCDP| or build the package from source:
|
||||
If your distribution doesn't provide a recent version of |MCC| (required version is |MCC_minversion|) you either
|
||||
can download a version of |MCC| from the |MCDP| or build the package from source:
|
||||
|
||||
.. code-block:: console
|
||||
.. code-block:: console
|
||||
|
||||
mkdir bld
|
||||
cd bld
|
||||
cmake ..
|
||||
make
|
||||
make install
|
||||
mkdir bld
|
||||
cd bld
|
||||
cmake ..
|
||||
make
|
||||
make install
|
||||
|
||||
|
||||
.. collapse:: Q: Does MariaDB Connector/Python provide pre-releases or snapshot builds which contain recent bug fixes?
|
||||
Q: Does MariaDB Connector/Python provide pre-releases or snapshot builds which contain recent bug fixes?
|
||||
--------------------------------------------------------------------------------------------------------
|
||||
|
||||
No. If an issue was fixed, the fix will be available in the next release via Python's package
|
||||
manager repository (pypi.org).
|
||||
No. If an issue was fixed, the fix will be available in the next release via Python's package
|
||||
manager repository (pypi.org).
|
||||
|
||||
.. collapse:: Q: How can I build an actual version from github sources?
|
||||
Q: How can I build an actual version from github sources?
|
||||
----------------------------------------------------------
|
||||
|
||||
To build |MCP| from github sources, checkout latest sources from github
|
||||
To build |MCP| from github sources, checkout latest sources from github:
|
||||
|
||||
.. code-block:: console
|
||||
.. code-block:: console
|
||||
|
||||
git clone https://github.com/mariadb-corporation/mariadb-conector-pyhon.git
|
||||
git clone https://github.com/mariadb-corporation/mariadb-connector-python.git
|
||||
|
||||
and build and install it with
|
||||
and build and install it with:
|
||||
|
||||
.. code-block:: console
|
||||
.. code-block:: console
|
||||
|
||||
python3 setup.py build
|
||||
python3 -m pip install .
|
||||
python3 setup.py build
|
||||
python3 -m pip install .
|
||||
|
||||
|
||||
Connecting
|
||||
^^^^^^^^^^
|
||||
|
||||
.. collapse:: mariadb.OperationalError: Can't connect to local server through socket '/tmp/mysql.sock'
|
||||
mariadb.OperationalError: Can't connect to local server through socket '/tmp/mysql.sock'
|
||||
-----------------------------------------------------------------------------------------
|
||||
|
||||
1. Check if MariaDB server has been started.
|
||||
1. Check if MariaDB server has been started.
|
||||
|
||||
2. Check if the MariaDB server was correctly configured and uses the right socket file:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
mysqld --help --verbose | grep socket
|
||||
|
||||
If the socket is different and cannot be changed, you can specify the socket in your
|
||||
connection parameters.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
connection= mariab.connect(unix_socket="/path_socket/mysql.sock", ....)
|
||||
|
||||
Another option is setting the environment variable MYSQL_UNIX_PORT.
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
export MYSQL_UNIX_PORT=/path_to/mysql.sock
|
||||
|
||||
.. collapse:: Q: Which authentication methods are supported by MariaDB Connector/Python?
|
||||
|
||||
|MCP| uses |MCC| for client-server communication. That means all authenticatoin plugins shipped
|
||||
together with |MCC| can be used for user authentication.
|
||||
|
||||
|
||||
General:
|
||||
^^^^^^^^
|
||||
|
||||
.. collapse:: Q: How do I execute multipe statements with cursor.execute() ?
|
||||
|
||||
Since |MCP| uses binary protocol for client-server communication, this feature is not supported yet.
|
||||
|
||||
.. collapse:: Q: Does MariaDB Connector/Python works with Python 2.x ?
|
||||
|
||||
Python versions which reached their end of life are not officially supported. While |MCP| might still work
|
||||
with older Python 3.x versions, it doesn't work with Python version 2.x.
|
||||
|
||||
.. collapse:: Q: How can I see a transformed statement? Is there a mogrify() method available?
|
||||
|
||||
No, |MCP| Python uses binary protocol for client/server communication. Before a statement will be executed
|
||||
it will be parsed and parameter markers which are different than question marks will be replaced by question
|
||||
marks. Afterwards the statement will be sent together with data to the server. The transformed statement can
|
||||
be obtained by cursor.statement attribute
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
data = ("Future", 2000)
|
||||
statement = """SELECT DATE_FORMAT(creation_time, '%h:%m:%s') as time, topic, amount
|
||||
FROM mytable WHERE topic=%s and id > %s"""
|
||||
cursor.execute(statement, data)
|
||||
print(cursor.statement)
|
||||
2. Check if the MariaDB server was correctly configured and uses the right socket file:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
SELECT DATE_FORMAT(creation_time, '%h:%m:%s') as time, topic, amount FROM mytable WHERE topic=? and id > ?
|
||||
mysqld --help --verbose | grep socket
|
||||
|
||||
Please note, that there is no need to escape '%s' by '%%s' for the time conversion in DATE_FORMAT() function.
|
||||
If the socket is different and cannot be changed, you can specify the socket in your
|
||||
connection parameters.
|
||||
|
||||
.. collapse:: Q: Does MariaDB Connector/Python supports paramstyle "pyformat" ?
|
||||
.. code-block:: python
|
||||
|
||||
The default paramstyle (see :PEP:`249`) is **qmark** (question mark) for parameter markers. For compatibility
|
||||
with other drivers |MCP| also supports (and automatically recognizes) the **format** and **pyformat** parameter
|
||||
styles.
|
||||
connection = mariadb.connect(unix_socket="/path_socket/mysql.sock", ....)
|
||||
|
||||
Mixing different paramstyles within the same query is not supported and will raise an exception.
|
||||
Another option is setting the environment variable MYSQL_UNIX_PORT.
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
export MYSQL_UNIX_PORT=/path_to/mysql.sock
|
||||
|
||||
Q: Which authentication methods are supported by MariaDB Connector/Python?
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
|MCP| uses |MCC| for client-server communication. That means all authentication plugins shipped
|
||||
together with |MCC| can be used for user authentication.
|
||||
|
||||
|
||||
General
|
||||
^^^^^^^
|
||||
|
||||
Q: How do I execute multiple statements with cursor.execute()?
|
||||
--------------------------------------------------------------
|
||||
|
||||
Since |MCP| uses binary protocol for client-server communication, this feature is not supported yet.
|
||||
|
||||
Q: Does MariaDB Connector/Python work with Python 2.x?
|
||||
-------------------------------------------------------
|
||||
|
||||
Python versions which reached their end of life are not officially supported. While |MCP| might still work
|
||||
with older Python 3.x versions, it doesn't work with Python version 2.x.
|
||||
|
||||
Q: How can I see a transformed statement? Is there a mogrify() method available?
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
No, |MCP| Python uses binary protocol for client/server communication. Before a statement will be executed
|
||||
it will be parsed and parameter markers which are different than question marks will be replaced by question
|
||||
marks. Afterwards the statement will be sent together with data to the server. The transformed statement can
|
||||
be obtained by cursor.statement attribute.
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
data = ("Future", 2000)
|
||||
statement = """SELECT DATE_FORMAT(creation_time, '%h:%m:%s') as time, topic, amount
|
||||
FROM mytable WHERE topic=%s and id > %s"""
|
||||
cursor.execute(statement, data)
|
||||
print(cursor.statement)
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
SELECT DATE_FORMAT(creation_time, '%h:%m:%s') as time, topic, amount FROM mytable WHERE topic=? and id > ?
|
||||
|
||||
Please note, that there is no need to escape '%s' by '%%s' for the time conversion in DATE_FORMAT() function.
|
||||
|
||||
Q: Does MariaDB Connector/Python support paramstyle "pyformat"?
|
||||
----------------------------------------------------------------
|
||||
|
||||
The default paramstyle (see :PEP:`249`) is **qmark** (question mark) for parameter markers. For compatibility
|
||||
with other drivers |MCP| also supports (and automatically recognizes) the **format** and **pyformat** parameter
|
||||
styles.
|
||||
|
||||
Mixing different paramstyles within the same query is not supported and will raise an exception.
|
||||
|
||||
|
||||
Transactions
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. collapse:: Q: Previously inserted records disappeared after my program finished.
|
||||
Q: Previously inserted records disappeared after my program finished
|
||||
---------------------------------------------------------------------
|
||||
|
||||
Default for autocommit in |MCP| is off, which means every transaction must be committed.
|
||||
Uncommitted pending transactions are rolled back automatically when the connection is closed.
|
||||
Default for autocommit in |MCP| is off, which means every transaction must be committed.
|
||||
Uncommitted pending transactions are rolled back automatically when the connection is closed.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
cursor= connection.cursor()
|
||||
cursor.execute("CREATE TABLE t1 (id int, name varchar(20))")
|
||||
with mariadb.connect(**conn_params) as conn:
|
||||
with conn.cursor() as cursor:
|
||||
cursor.execute("CREATE TABLE t1 (id int, name varchar(20))")
|
||||
|
||||
#insert
|
||||
data= [(1, "Andy"), (2, "George"), (3, "Betty")]
|
||||
cursor.executemany("INSERT INTO t1 VALUES (?,?)", data)
|
||||
|
||||
#commit pending transactions
|
||||
connection.commit()
|
||||
|
||||
#close handles
|
||||
cursor.close()
|
||||
connection.close()
|
||||
# insert
|
||||
data = [(1, "Andy"), (2, "George"), (3, "Betty")]
|
||||
cursor.executemany("INSERT INTO t1 VALUES (?,?)", data)
|
||||
|
||||
# commit pending transactions
|
||||
connection.commit()
|
||||
|
||||
{% @marketo/form formId=\"4316\" %}
|
@ -6,19 +6,16 @@ MariaDB Connector/Python
|
||||
|
||||
.. testsetup::
|
||||
|
||||
import mariadb
|
||||
conn_params= {
|
||||
"host" : "localhost",
|
||||
"database" : "test"
|
||||
}
|
||||
|
||||
conn=mariadb.connect(**conn_params)
|
||||
cursor=conn.cursor()
|
||||
cursor.execute("CREATE USER IF NOT EXISTS example_user@localhost identified by 'GHbe_Su3B8'")
|
||||
cursor.execute("grant all on test.* to example_user@localhost")
|
||||
cursor.execute("DROP TABLE IF EXISTS book")
|
||||
cursor.close()
|
||||
conn.close()
|
||||
import mariadb
|
||||
conn_params= {
|
||||
"host" : "localhost",
|
||||
"database" : "test"
|
||||
}
|
||||
with mariadb.connect(**conn_params) as conn:
|
||||
with conn.cursor() as cursor:
|
||||
cursor.execute("CREATE USER IF NOT EXISTS example_user@localhost identified by 'GHbe_Su3B8'")
|
||||
cursor.execute("grant all on test.* to example_user@localhost")
|
||||
cursor.execute("DROP TABLE IF EXISTS book")
|
||||
|
||||
|MCP| enables python programs to access MariaDB and MySQL databases, using an API
|
||||
which is compliant with the Python |DBAPI|. It is written in C and Python and uses
|
||||
@ -27,7 +24,7 @@ MariaDB Connector/C client library for client server communication.
|
||||
.. rubric:: Contents
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 3
|
||||
:maxdepth: 2
|
||||
:caption: Contents:
|
||||
|
||||
install
|
||||
@ -35,14 +32,7 @@ MariaDB Connector/C client library for client server communication.
|
||||
pooling
|
||||
api
|
||||
license
|
||||
release
|
||||
bugs
|
||||
faq
|
||||
|
||||
------------------
|
||||
Indices and tables
|
||||
------------------
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
||||
{% @marketo/form formId=\"4316\" %}
|
@ -1,8 +1,8 @@
|
||||
.. _installation:
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
.. _installation:
|
||||
|
||||
.. sectionauthor:: Georg Richter <georg@mariadb.com>
|
||||
|
||||
Prerequisites
|
||||
@ -97,3 +97,5 @@ You can configure the connection parameters by using the following environment v
|
||||
* TEST_DB_DATABASE (default 'testp')
|
||||
* TEST_DB_HOST (default 'localhost')
|
||||
* TEST_DB_PORT (default 3306)
|
||||
|
||||
{% @marketo/form formId=\"4316\" %}
|
@ -19,5 +19,5 @@ MariaDB Connector/Python documentation
|
||||
- Attribution -- You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
|
||||
- No additional restrictions —- You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
|
||||
|
||||
|
||||
{% @marketo/form formId=\"4316\" %}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
.. _module:
|
||||
|
||||
The MariaDB Connector/Python module
|
||||
===================================
|
||||
|
||||
.. _module:
|
||||
|
||||
.. sectionauthor:: Georg Richter <georg@mariadb.com>
|
||||
|
||||
.. automodule:: mariadb
|
||||
@ -24,11 +24,10 @@ Example:
|
||||
|
||||
.. testcode::
|
||||
|
||||
import mariadb
|
||||
import mariadb
|
||||
|
||||
connection= mariadb.connect(user="example_user", host="localhost", database="test", password="GHbe_Su3B8")
|
||||
|
||||
print(connection.character_set)
|
||||
with mariadb.connect(user="example_user", host="localhost", database="test", password="GHbe_Su3B8") as connection:
|
||||
print(connection.character_set)
|
||||
|
||||
Output:
|
||||
|
||||
@ -83,16 +82,17 @@ Attributes
|
||||
|
||||
String constant stating the version of the used MariaDB Connector/C library.
|
||||
|
||||
.. versionadded:: 1.1.0
|
||||
.. attribute:: client_version
|
||||
|
||||
*Since version 1.1.0*
|
||||
|
||||
Returns the version of MariaDB Connector/C library in use as an integer.
|
||||
The number has the following format:
|
||||
MAJOR_VERSION * 10000 + MINOR_VERSION * 1000 + PATCH_VERSION
|
||||
|
||||
.. versionadded:: 1.1.0
|
||||
.. attribute:: client_version_info
|
||||
|
||||
*Since version 1.1.0*
|
||||
Returns the version of MariaDB Connector/C library as a tuple in the
|
||||
following format:
|
||||
(MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION)
|
||||
@ -176,3 +176,5 @@ Output:
|
||||
|
||||
This type object is not supported in MariaDB Connector/Python and represents
|
||||
an empty set.
|
||||
|
||||
{% @marketo/form formId=\"4316\" %}
|
@ -22,15 +22,17 @@ ConnectionPool methods
|
||||
ConnectionPool attributes
|
||||
-------------------------
|
||||
|
||||
.. versionadded:: 1.1.0
|
||||
.. autoattribute:: mariadb.ConnectionPool.connection_count
|
||||
|
||||
*Since version 1.1.0*
|
||||
|
||||
.. autoattribute:: mariadb.ConnectionPool.max_size
|
||||
|
||||
.. autoattribute:: mariadb.ConnectionPool.pool_size
|
||||
|
||||
.. autoattribute:: mariadb.ConnectionPool.pool_name
|
||||
|
||||
.. versionadded:: 1.1.0
|
||||
.. autoattribute:: mariadb.ConnectionPool.pool_reset_connection
|
||||
*Since version 1.1.0*
|
||||
|
||||
{% @marketo/form formId=\"4316\" %}
|
@ -29,13 +29,10 @@ When creating a connection pool, the following parameters have to be provided:
|
||||
|
||||
1. Connection pool specific parameters
|
||||
|
||||
- pool_name: The name of the pool, if not specified |MCP| will raise an exception.
|
||||
- pool_size: The size of the pool, if not specified a default of 5 will be set.
|
||||
- pool_reset_session: If set to True, the connection will be resetted before returned to the pool
|
||||
|
||||
.. versionadded:: 1.1.0
|
||||
|
||||
- pool_invalidation_interval: specifies the validation interval in milliseconds after which the status of a connection requested from the pool is checked. The default values is 500 milliseconds, a value of 0 means that the status will always be checked.
|
||||
- **`pool_name`**: The name of the pool, if not specified |MCP| will raise an exception.
|
||||
- **`pool_size`**: The size of the pool, if not specified a default of 5 will be set.
|
||||
- **`pool_reset_session`**: If set to True, the connection will be reset before returned to the pool
|
||||
- **`pool_invalidation_interval`**: specifies the validation interval in milliseconds after which the status of a connection requested from the pool is checked. The default values is 500 milliseconds, a value of 0 means that the status will always be checked. Since 1.1.0
|
||||
|
||||
|
||||
2. Connection parameters
|
||||
@ -56,17 +53,14 @@ When creating a connection pool, the following parameters have to be provided:
|
||||
}
|
||||
|
||||
# create new pool
|
||||
pool= mariadb.ConnectionPool(pool_name="myfirstpool", pool_size=5, **conn_params)
|
||||
print("Pool size of '%s': %s" % (pool.pool_name, pool.pool_size))
|
||||
with mariadb.ConnectionPool(pool_name="myfirstpool", pool_size=5, **conn_params) as pool:
|
||||
print("Pool size of '%s': %s" % (pool.pool_name, pool.pool_size))
|
||||
|
||||
# get a connection from pool
|
||||
conn= pool.get_connection()
|
||||
# get a connection from pool
|
||||
with pool.get_connection() as conn:
|
||||
|
||||
# print the default database for connection
|
||||
print("Current database: %s" % conn.database)
|
||||
|
||||
# close connection and return it to pool
|
||||
conn.close()
|
||||
# print the default database for connection
|
||||
print("Current database: %s" % conn.database)
|
||||
|
||||
*Output*:
|
||||
|
||||
@ -75,3 +69,4 @@ When creating a connection pool, the following parameters have to be provided:
|
||||
Pool size of 'myfirstpool': 5
|
||||
Current database: test
|
||||
|
||||
{% @marketo/form formId=\"4316\" %}
|
@ -1,365 +0,0 @@
|
||||
Release history
|
||||
===============
|
||||
|
||||
MariaDB Connector/Python 1.1.12
|
||||
-------------------------------
|
||||
|
||||
Release date: Feb 24 2025
|
||||
|
||||
**Notable changes:**
|
||||
- :conpy:`299`: Added support for VECTOR: Vectors can be directly used in parameters as float arrays without using tobytes() method or SQL Function Vec_FromText()
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- :conpy:`295`: Fix unsigned check when using executemany() method
|
||||
- :conpy:`300`: Documentation fix (ConnectionPool)
|
||||
- :conpy:`302`: Fix segfault when using threads()
|
||||
- Fixed exception type for ER_BAD_FIELD_ERROR (now OperationalError instead of ProgrammingError)
|
||||
|
||||
|
||||
MariaDB Connector/Python 1.1.11
|
||||
-------------------------------
|
||||
|
||||
Release date: Nov 14 2024
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- :conpy:`283`: Incorrect result format after cursor.scroll()
|
||||
- :conpy:`289`: BIGINT out of range on bulk insert
|
||||
- :conpy:`293`: Fix gcc warnings
|
||||
|
||||
**Notable changes:**
|
||||
- Added new connection attribute tls_peer_cert_info
|
||||
- Added support for MariaDB Connector/C 3.4
|
||||
|
||||
|
||||
|
||||
MariaDB Connector/Python 1.1.10
|
||||
-------------------------------
|
||||
|
||||
Release date: Feb 07 2024
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- :conpy:`273`: cursor.execute fails when running in sql_mode ANSI_QUOTES.
|
||||
- :conpy:`278`: Return updated connection_id in case of automatic reconnect
|
||||
- :conpy:`279`: Allow None values for password and database in change_user() method
|
||||
- :conpy:`281`: Use METH_O calling conventions for c functions which accept only one parameter
|
||||
|
||||
MariaDB Connector/Python 1.1.9
|
||||
------------------------------
|
||||
|
||||
Release date: Dec 22 2023
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- :conpy:`273`: Fixed crash in escape_string method (debug)
|
||||
|
||||
- :conpy:`274`: Instead of releasing non freed objects (cursor and connection) in tp_dealloc, they are freed now in tp_finalize to avoid possible crashes
|
||||
|
||||
- :conpy:`276`: Allow to retrieve data from buffered cursor if the connection was already closed before
|
||||
|
||||
MariaDB Connector/Python 1.1.8
|
||||
------------------------------
|
||||
|
||||
Release date: Oct 12 2023
|
||||
|
||||
**Notable changes:**
|
||||
|
||||
- :conpy:`271`: Cusor object provides now a metadata attribute, which returns resultset metadata as a dictionary. metadata attribute also contains information about extended field types like JSON, UUID, INET4/6 and geometry types.
|
||||
|
||||
- Added new constants `mariadb.constants.EXT_FIELD_TYPE` which describe extended field types.
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
|
||||
- :conpy:`270`: Data will be converted to Binary only if the character set is binary, the BINARY_FLAG will be ignored.
|
||||
|
||||
- :conpy:`269`: If cursors rowcount attribute will be retrieved after the cursor was closed, rowcount now returns -1 instead of raising an exception. This is a workaround for a pandas bug.
|
||||
|
||||
|
||||
MariaDB Connector/Python 1.1.7
|
||||
------------------------------
|
||||
|
||||
Release date: Jul 5 2023
|
||||
|
||||
**Notable changes:**
|
||||
|
||||
|
||||
- :conpy:`253`: The connection method now offers the option of specifying the version of the TLS protocol using tls_version.
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
|
||||
- :conpy:`258`: Fixed ValueError exception if ZEROFILL flag is defined.
|
||||
- :conpy:`256`: Fix indexing when moving a free connection to used connections to avoid returning the same connection twice. Kudos and thanks to G.Mech for reporting this bug and providing the fix.
|
||||
- :conpy:`255`: If all connections from a pool are in use, pool.get_connection now returns None instead of raising an exception.
|
||||
|
||||
|
||||
MariaDB Connector/Python 1.1.6
|
||||
------------------------------
|
||||
|
||||
Release date: Feb 20 2023
|
||||
|
||||
**Notable changes:**
|
||||
|
||||
|
||||
- :conpy:`247`: Added optional parameter "pool_invalidation_interval", which specifies the validation interval in milliseconds after which the status of a connection requested from the pool is checked. The default values is 500 milliseconds, a value of 0 means that the status will always be checked.
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
|
||||
- :conpy:`251`: Check if stmt was already initialized in cursor nextset() method.
|
||||
- :conpy:`250`: Fixed calculation of connection pool size
|
||||
- :conpy:`248`: Replace broken connections in connection pool
|
||||
- :conpy:`246`: Rollback transaction if connection pool was created without pool_reset_connection option.
|
||||
- :conpy:`245`: Implementation of LRU cache in connection pool.
|
||||
- :conpy:`240`: Don't overwrite errormessage/stacktrace if an exception was generated during module initialization.
|
||||
|
||||
|
||||
|
||||
MariaDB Connector/Python 1.1.5
|
||||
------------------------------
|
||||
|
||||
Release date: Nov 7 2022
|
||||
|
||||
**Notable changes:**
|
||||
|
||||
|
||||
- Since Connector/C 3.2 is discontinued, minimum required version for MariaDB Connector/Python 1.1.5 is Connector/C 3.3.1
|
||||
- :conpy:`220`: Added _get_socket() method
|
||||
- Performance improvement: Instead of iterating via fetchone(), fetchall() and fetchmany() methods now load the data directly at once.
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
|
||||
- :conpy:`222`: Removed del() method from cursor
|
||||
- :conpy:`224`: Fixed bulk_operation when reexecuted using same cursor
|
||||
- :conpy:`225`: Fixed cursor.affected_rows property
|
||||
- :conpy:`226`: Replaced deprecated distutils (PEP-632)
|
||||
- :conpy:`227`: Replaced collections.named_tuple by PyStruct_Sequence (C-Python)
|
||||
- .conpy:`228`: Fixed Installation error (if C/C version < 3.2.4 was found)
|
||||
- .conpy:`229`: Converter: added missing support for None conversions
|
||||
- .conpy:`231`: Fixed memory leak
|
||||
|
||||
MariaDB Connector/Python 1.1.4
|
||||
------------------------------
|
||||
|
||||
Release date: Aug 10 2022
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- :conpy:`217`: Added reconnect keyword for connection
|
||||
- Added CAPABILITY constants
|
||||
- Code styling fixes (flake8)
|
||||
- :conpy:`218`: Allow None as data parameter in cursor->execute(). Kudos to Luciano Barcaro for providing a fix
|
||||
- :conpy:`214`: Replaced cursor iterator by native Python iter() method.
|
||||
|
||||
MariaDB Connector/Python 1.1.3
|
||||
------------------------------
|
||||
Release date: Jul 07 2022
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
- :conpy:`209`: Wrong unicode substitution in SELECT statement
|
||||
- :conpy:`210`: Added missing error constants
|
||||
- :conpy:`212`: unbuffered cursor.execute() doesn't work
|
||||
|
||||
MariaDB Connector/Python 1.1.2
|
||||
-------------------------------
|
||||
Release date: Jun 27 2022
|
||||
|
||||
**Notable changes:**
|
||||
|
||||
- :conpy:`203`: Error constants added
|
||||
- :conpy:`204`: New connection method dump_debug_info(
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
Removed utf8 part of internal parser and use binary objects for parameter substitution
|
||||
- :conpy:`205`: Fixed inconsistent exceptions: All parameter exceptions are returned as ProgrammingError.
|
||||
Fixed memory leak when using decimal parameters
|
||||
- :conpy:`201`: Fixed build issues with Python 3.11 beta
|
||||
|
||||
|
||||
MariaDB Connector/Python 1.0.11
|
||||
-------------------------------
|
||||
|
||||
Release date: Apr 12 2022
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
|
||||
- :conpy:`194`: executemany() does not work with returning clause
|
||||
- :conpy:`196`: Missing decrement of reference pointer when closing cursor
|
||||
- :conpy:`198`: Build fix for FreeBSD
|
||||
|
||||
MariaDB Connector/Pyhon 1.0.10
|
||||
------------------------------
|
||||
|
||||
Release date: Feb 18 2022
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
|
||||
- - :conpy:`184`: Display status of connection, cursor and pool class in string representation.
|
||||
- - :conpy:`178`: Repeated execution of cursors callproc() method hangs
|
||||
- - :conpy:`175`: Fixed crash in escape_string
|
||||
|
||||
MariaDB Connector/Python 1.0.9
|
||||
------------------------------
|
||||
|
||||
Release date: Dec 21 2021
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
|
||||
- :conpy:`184`: Display status of connection, cursor and pool class in string representation.
|
||||
- :conpy:`178`: Repeated execution of cursors callproc() method hangs
|
||||
- :conpy:`175`: Fixed crash in escape_string
|
||||
|
||||
MariaDB Connector/Python 1.0.8
|
||||
------------------------------
|
||||
|
||||
Release date: Oct 22 2021
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
|
||||
- :conpy:`173`: Fixed windows build for Python 3.10
|
||||
|
||||
|
||||
MariaDB Connector/Python 1.0.7
|
||||
------------------------------
|
||||
|
||||
Release date: Jun 8 2021
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
|
||||
- :conpy:`155`: fixed crash in get_server_version method of connection class
|
||||
- :conpy:`144`: fixed crash in connection pool
|
||||
- :conpy:`150`: convert invalid date types (day, month or year=0) to NULL
|
||||
|
||||
MariaDB Connector/Python 1.0.6
|
||||
------------------------------
|
||||
|
||||
Release date: Feb 24 2021
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
|
||||
- :conpy:`142`: Fixed memory leak in connection class (server_version_info)
|
||||
- :conpy:`138`, :conpy:`141`: When using binary protocol, convert data to binary object only if the character set is BINARY (63), not if the flag was set and character set is a non binary character set.
|
||||
- Various build and travis related corrections/fixes.
|
||||
|
||||
MariaDB Connector/Python 1.0.5
|
||||
------------------------------
|
||||
|
||||
Release date: Nov 25th 2020
|
||||
|
||||
**Notable changes:**
|
||||
|
||||
|
||||
- :conpy:`127`: When establishing a new database connection the connect method now also supports None values instead of strings only.
|
||||
- :conpy:`128`: Added connection attribute server_version_info and (for compatibility) get_server_version() method. Both return a tuple, describing the version number of connected server in following format: (MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION)
|
||||
- :conpy:`133`: The internal parser now supports the full MariaDB comment syntax
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
|
||||
- :conpy:`126`: Fixed memory leak in connection object
|
||||
- :conpy:`130`: Fixed DeprecationWarning: builtin type Row has no module attribute
|
||||
- :conpy:`131`: Fixed crash type_traverse() called for non-heap type Row (Python 3.6 only)
|
||||
- :conpy:`132`: Fixed memory leak in connection pool
|
||||
|
||||
MariaDB Connector/Python 1.0.4
|
||||
------------------------------
|
||||
|
||||
Release date: Oct 20th 2020
|
||||
|
||||
**Notable changes:**
|
||||
|
||||
|
||||
Binary wheel packages are now availble for Windows on http://pypi.org
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
|
||||
- :conpy:`123`: Free pending result sets when closing cursor
|
||||
- :conpy:`124`: Fix build when building against Connector/C < 3.1.8
|
||||
- :conpy:`125`: Build fix: replace obsolete ULONG_LONG_MAX definitions
|
||||
|
||||
MariaDB Connector/Python 1.0.3
|
||||
------------------------------
|
||||
|
||||
Release date: Oct 7th 2020
|
||||
|
||||
**Notable changes:**
|
||||
|
||||
|
||||
- :conpy:`117`: Added support for data type conversion.
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
|
||||
- :conpy:`116`: Wrong type reporting for column type MYSQL_TYPE_JSON
|
||||
- :conpy:`118`: Removed statement allocation for text protocol
|
||||
- :conpy:`119`: Fixed memory leak when cursor result is dictionary
|
||||
|
||||
MariaDB Connector/Python 1.0.2
|
||||
------------------------------
|
||||
|
||||
Release date: Sept 18th 2020
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
|
||||
- Fixed datetime initialization
|
||||
- :conpy:`108`: Fixed memory leak
|
||||
- :conpy:`110`: Fixed memory overrun when passing ssl keyword to connect() method.
|
||||
|
||||
MariaDB Connector/Python 1.0.1
|
||||
------------------------------
|
||||
|
||||
Release date: August 18th 2020
|
||||
|
||||
**Notable changes:**
|
||||
|
||||
|
||||
- :conpy:`100`: added binary option for cursor which allows to use binary protocol without passing parameters
|
||||
- :conpy:`102`: Default for autocommit is now off
|
||||
- :conpy:`105`: Behavior of rowcount and lastrowid atttributes now conforms to PEP-249
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
|
||||
- :conpy:`82`: Unlock mutex in case of ConnectionPool.add_connection failed
|
||||
- :conpy:`83`: Fixed missing reference increment in ConnectionPool class
|
||||
- :conpy:`85`: Fixed version checking in setup.py
|
||||
- :conpy:`93`: Release GIL before calling Python's memory allocation routine
|
||||
- :conpy:`94`: Support python subclasses for data binding
|
||||
- :conpy:`95`: Added support for MYSQL_TYPE_BIT column type
|
||||
- :conpy:`98`: Return binary object when casting to binary
|
||||
- :conpy:`99`: Fixed memory leak in fetchall() method.
|
||||
- :conpy:`101`: Fixed negative reference count when using callproc() method.
|
||||
- :conpy:`106`: exception handling: type of exception depends now on error code instead of sqlstate
|
||||
- :conpy:`107`: convert negative time values to datetime.timedelta instances
|
||||
|
||||
MariaDB Connector/Python 1.0.0
|
||||
------------------------------
|
||||
|
||||
Release date: June 24th 2020
|
||||
|
||||
**Issues fixed:**
|
||||
|
||||
|
||||
- :conpy:`69`: Set default character set (utf8mb4) with authentication packet
|
||||
- :conpy:`70`: set_config() method needs to check the passed parameter and raise an exception if the parameter type is not a dictionary.
|
||||
- :conpy:`72`: When deallocating the connection pool class, we need to check beside pool_size if the array containing the connections is valid.
|
||||
- :conpy:`76`: Added aliases username, passwd and db to connection keywords.
|
||||
- :conpy:`78`: Since MaxScale doesn't support bulk operations yet, we have to check servers extended capability flag to determine if this feature is supported or not.
|
||||
- :conpy:`79`: When inserting NULL values with executemany() method on a server which doesn't support BULK statements NULL values weren't inserted correctly.
|
||||
- :conpy:`80`: Parameters in set_config() method of ConnectionPool class have to be checked against the list of DSN keywords
|
||||
- :conpy:`81`: Fixed crash when switching between text and binary protocol with same cursor
|
||||
- Fixed bug when inserting negative integer values with cursor.execute() method
|
@ -14,21 +14,20 @@ Below is a simple example of a typical use of MariaDB Connector/Python
|
||||
|
||||
.. testsetup::
|
||||
|
||||
import mariadb
|
||||
import mariadb
|
||||
|
||||
# connection parameters
|
||||
conn_params= {
|
||||
"user" : "example_user",
|
||||
"password" : "GHbe_Su3B8",
|
||||
"host" : "localhost",
|
||||
"database" : "test"
|
||||
}
|
||||
# connection parameters
|
||||
conn_params= {
|
||||
"user" : "example_user",
|
||||
"password" : "GHbe_Su3B8",
|
||||
"host" : "localhost",
|
||||
"database" : "test"
|
||||
}
|
||||
|
||||
# Establish a connection
|
||||
connection= mariadb.connect(**conn_params)
|
||||
|
||||
cursor= connection.cursor()
|
||||
cursor.execute("CREATE OR REPLACE TABLE `countries` ("
|
||||
# Establish a connection
|
||||
with mariadb.connect(**conn_params) as conn:
|
||||
with conn.cursor() as cursor:
|
||||
cursor.execute("CREATE OR REPLACE TABLE `countries` ("
|
||||
"`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
|
||||
"`name` varchar(50) NOT NULL,"
|
||||
"`country_code` char(3) NOT NULL,"
|
||||
@ -38,9 +37,6 @@ Below is a simple example of a typical use of MariaDB Connector/Python
|
||||
"KEY `capital` (`capital`)"
|
||||
") ENGINE=InnoDB DEFAULT CHARSET=latin1")
|
||||
|
||||
cursor.close()
|
||||
connection.close()
|
||||
|
||||
.. testcode::
|
||||
|
||||
import mariadb
|
||||
@ -54,24 +50,18 @@ Below is a simple example of a typical use of MariaDB Connector/Python
|
||||
}
|
||||
|
||||
# Establish a connection
|
||||
connection= mariadb.connect(**conn_params)
|
||||
with mariadb.connect(**conn_params) as conn:
|
||||
with conn.cursor() as cursor:
|
||||
# Populate countries table with some data
|
||||
cursor.execute("INSERT INTO countries(name, country_code, capital) VALUES (?,?,?)",
|
||||
("Germany", "GER", "Berlin"))
|
||||
|
||||
cursor= connection.cursor()
|
||||
# retrieve data
|
||||
cursor.execute("SELECT name, country_code, capital FROM countries")
|
||||
|
||||
# Populate countries table with some data
|
||||
cursor.execute("INSERT INTO countries(name, country_code, capital) VALUES (?,?,?)",
|
||||
("Germany", "GER", "Berlin"))
|
||||
|
||||
# retrieve data
|
||||
cursor.execute("SELECT name, country_code, capital FROM countries")
|
||||
|
||||
# print content
|
||||
row= cursor.fetchone()
|
||||
print(*row, sep=' ')
|
||||
|
||||
# free resources
|
||||
cursor.close()
|
||||
connection.close()
|
||||
# print content
|
||||
row= cursor.fetchone()
|
||||
print(*row, sep=' ')
|
||||
|
||||
*Output*:
|
||||
|
||||
@ -120,27 +110,20 @@ Since |MCP| uses binary protocol, escaping strings or binary data like in other
|
||||
}
|
||||
|
||||
# Establish a connection
|
||||
connection= mariadb.connect(**conn_params)
|
||||
with mariadb.connect(**conn_params) as conn:
|
||||
with conn.cursor() as cursor:
|
||||
sql= "INSERT INTO countries (name, country_code, capital) VALUES (?,?,?)"
|
||||
data= ("Germany", "GER", "Berlin")
|
||||
cursor.execute(sql, data)
|
||||
|
||||
cursor= connection.cursor()
|
||||
|
||||
sql= "INSERT INTO countries (name, country_code, capital) VALUES (?,?,?)"
|
||||
data= ("Germany", "GER", "Berlin")
|
||||
cursor.execute(sql, data)
|
||||
|
||||
connection.commit()
|
||||
|
||||
# delete last entry
|
||||
sql= "DELETE FROM countries WHERE country_code=?"
|
||||
data= ("GER",)
|
||||
cursor.execute(sql, data)
|
||||
|
||||
connection.commit()
|
||||
|
||||
cursor.close()
|
||||
connection.close()
|
||||
conn.commit()
|
||||
|
||||
# delete last entry
|
||||
sql= "DELETE FROM countries WHERE country_code=?"
|
||||
data= ("GER",)
|
||||
cursor.execute(sql, data)
|
||||
|
||||
conn.commit()
|
||||
|
||||
|
||||
Often there is a requirement to update, delete or insert multiple records. This could be done be using :func:`~execute` in
|
||||
@ -159,47 +142,43 @@ a loop, but much more effective is using the :func:`executemany` method, especia
|
||||
}
|
||||
|
||||
# Establish a connection
|
||||
connection= mariadb.connect(**conn_params)
|
||||
with mariadb.connect(**conn_params) as connection:
|
||||
with connection.cursor() as cursor:
|
||||
sql= "INSERT INTO countries (name, country_code, capital) VALUES (?,?,?)"
|
||||
|
||||
cursor= connection.cursor()
|
||||
sql= "INSERT INTO countries (name, country_code, capital) VALUES (?,?,?)"
|
||||
data= [("Ireland", "IE", "Dublin"),
|
||||
("Italy", "IT", "Rome"),
|
||||
("Malaysia", "MY", "Kuala Lumpur"),
|
||||
("France", "FR", "Paris"),
|
||||
("Iceland", "IS", "Reykjavik"),
|
||||
("Nepal", "NP", "Kathmandu")]
|
||||
|
||||
data= [("Ireland", "IE", "Dublin"),
|
||||
("Italy", "IT", "Rome"),
|
||||
("Malaysia", "MY", "Kuala Lumpur"),
|
||||
("France", "FR", "Paris"),
|
||||
("Iceland", "IS", "Reykjavik"),
|
||||
("Nepal", "NP", "Kathmandu")]
|
||||
# insert data
|
||||
cursor.executemany(sql, data)
|
||||
|
||||
# insert data
|
||||
cursor.executemany(sql, data)
|
||||
# Since autocommit is off by default, we need to commit last transaction
|
||||
connection.commit()
|
||||
|
||||
# Since autocommit is off by default, we need to commit last transaction
|
||||
connection.commit()
|
||||
# Instead of 3 letter country-code, we inserted 2 letter country code, so
|
||||
# let's fix this mistake by updating data
|
||||
sql= "UPDATE countries SET country_code=? WHERE name=?"
|
||||
data= [("Ireland", "IRL"),
|
||||
("Italy", "ITA"),
|
||||
("Malaysia", "MYS"),
|
||||
("France", "FRA"),
|
||||
("Iceland", "ISL"),
|
||||
("Nepal", "NPL")]
|
||||
cursor.executemany(sql, data)
|
||||
|
||||
# Instead of 3 letter country-code, we inserted 2 letter country code, so
|
||||
# let's fix this mistake by updating data
|
||||
sql= "UPDATE countries SET country_code=? WHERE name=?"
|
||||
data= [("Ireland", "IRL"),
|
||||
("Italy", "ITA"),
|
||||
("Malaysia", "MYS"),
|
||||
("France", "FRA"),
|
||||
("Iceland", "ISL"),
|
||||
("Nepal", "NPL")]
|
||||
cursor.executemany(sql, data)
|
||||
# Now let's delete all non European countries
|
||||
sql= "DELETE FROM countries WHERE name=?"
|
||||
data= [("Malaysia",), ("Nepal",)]
|
||||
cursor.executemany(sql, data)
|
||||
|
||||
# Now let's delete all non European countries
|
||||
sql= "DELETE FROM countries WHERE name=?"
|
||||
data= [("Malaysia",), ("Nepal",)]
|
||||
cursor.executemany(sql, data)
|
||||
# by default autocommit is off, so we need to commit
|
||||
# our transactions
|
||||
connection.commit()
|
||||
|
||||
# by default autocommit is off, so we need to commit
|
||||
# our transactions
|
||||
connection.commit()
|
||||
|
||||
# free resources
|
||||
cursor.close()
|
||||
connection.close()
|
||||
|
||||
When using executemany(), there are a few restrictions:
|
||||
- All tuples must have the same types as in first tuple. E.g. the parameter [(1),(1.0)] or [(1),(None)] are invalid.
|
||||
@ -226,16 +205,14 @@ In certain situations, for example when inserting default values or NULL, specia
|
||||
}
|
||||
|
||||
# Establish a connection
|
||||
connection= mariadb.connect(**conn_params)
|
||||
with mariadb.connect(**conn_params) as connection:
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute("DROP TABLE IF EXISTS cakes")
|
||||
cursor.execute("CREATE TABLE cakes(id int, cake varchar(100), price decimal(10,2) default 1.99)")
|
||||
|
||||
cursor= connection.cursor()
|
||||
|
||||
cursor.execute("DROP TABLE IF EXISTS cakes")
|
||||
cursor.execute("CREATE TABLE cakes(id int, cake varchar(100), price decimal(10,2) default 1.99)")
|
||||
|
||||
sql= "INSERT INTO cakes (id, cake, price) VALUES (?,?,?)"
|
||||
data= [(1, "Cherry Cake", 2.10), (2, "Apple Cake", INDICATOR.DEFAULT)]
|
||||
cursor.executemany(sql, data)
|
||||
sql= "INSERT INTO cakes (id, cake, price) VALUES (?,?,?)"
|
||||
data= [(1, "Cherry Cake", 2.10), (2, "Apple Cake", INDICATOR.DEFAULT)]
|
||||
cursor.executemany(sql, data)
|
||||
|
||||
Beside the default indicator which inserts the default value of 1.99, the following indicators are supported:
|
||||
* INDICATOR.IGNORE: Ignores the value (only update commands)
|
||||
@ -282,3 +259,5 @@ Several standard python types are converted into SQL types and returned as Pytho
|
||||
- TIME
|
||||
* - Timestamp
|
||||
- TIMESTAMP
|
||||
|
||||
{% @marketo/form formId=\"4316\" %}
|
@ -44,95 +44,42 @@ def connect(*args, connectionclass=mariadb.connections.Connection, **kwargs):
|
||||
"""
|
||||
Creates a MariaDB Connection object.
|
||||
|
||||
By default the standard connectionclass mariadb.connections.Connection
|
||||
By default, the standard connectionclass mariadb.connections.Connection
|
||||
will be created.
|
||||
|
||||
Parameter connectionclass specifies a subclass of
|
||||
mariadb.Connection object. If not specified default will be used.
|
||||
mariadb.Connection object. If not specified, default will be used.
|
||||
This optional parameter was added in version 1.1.0.
|
||||
|
||||
Connection parameters are provided as a set of keyword arguments:
|
||||
- host:
|
||||
The host name or IP address of the database server.
|
||||
If MariaDB Connector/Python was built with MariaDB Connector/C 3.3
|
||||
it is also possible to provide a comma separated list of hosts for
|
||||
simple fail over in case of one or more hosts are not available.
|
||||
- user, username:
|
||||
The username used to authenticate with the database server
|
||||
- password, passwd:
|
||||
The password of the given user
|
||||
- database, db:
|
||||
database (schema) name to use when connecting with the database
|
||||
server
|
||||
- unix_socket:
|
||||
The location of the unix socket file to use instead of using an IP
|
||||
port to connect. If socket authentication is enabled, this can also
|
||||
be used in place of a password.
|
||||
- port:
|
||||
port number of the database server. If not specified the default
|
||||
value of 3306 will be used.
|
||||
- connect_timeout:
|
||||
connect timeout in seconds
|
||||
- read_timeout:
|
||||
read timeout in seconds
|
||||
- write_timeout:
|
||||
write timeout in seconds
|
||||
- local_infile:
|
||||
Enables or disables the use of LOAD DATA LOCAL INFILE statements.
|
||||
- compress= False:
|
||||
Uses the compressed protocol for client server communication. If
|
||||
the server doesn't support compressed protocol, the default
|
||||
protocol will be used.
|
||||
- init_command:
|
||||
Command(s) which will be executed when connecting and reconnecting
|
||||
to the database server
|
||||
- default_file:
|
||||
Read options from the specified option file. If the file is an
|
||||
empty string, default configuration file(s) will be used
|
||||
- default_group:
|
||||
Read options from the specified group
|
||||
- plugin_dir:
|
||||
Directory which contains MariaDB client plugins.
|
||||
- reconnect:
|
||||
Enables or disables automatic reconnect. Available since
|
||||
version 1.1.4
|
||||
- ssl_key:
|
||||
Defines a path to a private key file to use for TLS. This option
|
||||
requires that you use the absolute path, not a relative path. The
|
||||
specified key must be in PEM format
|
||||
- ssl_cert:
|
||||
Defines a path to the X509 certificate file to use for TLS.
|
||||
This option requires that you use the absolute path, not a relative
|
||||
path. The X609 certificate must be in PEM format.
|
||||
- ssl_ca:
|
||||
Defines a path to a PEM file that should contain one or more X509
|
||||
certificates for trusted Certificate Authorities (CAs) to use for
|
||||
TLS. This option requires that you use the absolute path, not a
|
||||
relative path.
|
||||
- ssl_capath:
|
||||
Defines a path to a directory that contains one or more PEM files
|
||||
that contains one X509 certificate for a trusted Certificate
|
||||
Authority (CA)
|
||||
- ssl_cipher:
|
||||
Defines a list of permitted cipher suites to use for TLS
|
||||
- ssl_crlpath:
|
||||
Defines a path to a PEM file that should contain one or more
|
||||
revoked X509 certificates to use for TLS. This option requires
|
||||
that you use the absolute path, not a relative path.
|
||||
- ssl_verify_cert:
|
||||
Enables server certificate verification.
|
||||
- ssl:
|
||||
The connection must use TLS security or it will fail.
|
||||
- tls_version:
|
||||
A comma-separated list (without whitespaces) of TLS versions.
|
||||
Valid versions are TLSv1.0, TLSv1.1,TLSv1.2 and TLSv1.3.
|
||||
Added in version 1.1.7.
|
||||
- autocommit=False:
|
||||
Specifies the autocommit settings.
|
||||
True will enable autocommit, False will disable it (default).
|
||||
- converter:
|
||||
Specifies a conversion dictionary, where keys are FIELD_TYPE
|
||||
values and values are conversion functions
|
||||
|
||||
- **`host`** - The host name or IP address of the database server. If MariaDB Connector/Python was built with MariaDB Connector/C 3.3, it is also possible to provide a comma separated list of hosts for simple fail over in case of one or more hosts are not available.
|
||||
- **`user`, `username`** - The username used to authenticate with the database server
|
||||
- **`password`, `passwd`** - The password of the given user
|
||||
- **`database`, `db`** - Database (schema) name to use when connecting with the database server
|
||||
- **`unix_socket`** - The location of the unix socket file to use instead of using an IP port to connect. If socket authentication is enabled, this can also be used in place of a password.
|
||||
- **`port`** - Port number of the database server. If not specified, the default value of 3306 will be used.
|
||||
- **`connect_timeout`** - Connect timeout in seconds
|
||||
- **`read_timeout`** - Read timeout in seconds
|
||||
- **`write_timeout`** - Write timeout in seconds
|
||||
- **`local_infile`** - Enables or disables the use of LOAD DATA LOCAL INFILE statements.
|
||||
- **`compress`** (default: `False`) - Uses the compressed protocol for client server communication. If the server doesn't support compressed protocol, the default protocol will be used.
|
||||
- **`init_command`** - Command(s) which will be executed when connecting and reconnecting to the database server
|
||||
- **`default_file`** - Read options from the specified option file. If the file is an empty string, default configuration file(s) will be used
|
||||
- **`default_group`** - Read options from the specified group
|
||||
- **`plugin_dir`** - Directory which contains MariaDB client plugins.
|
||||
- **`reconnect`** - Enables or disables automatic reconnect. Available since version 1.1.4
|
||||
- **`ssl_key`** - Defines a path to a private key file to use for TLS. This option requires that you use the absolute path, not a relative path. The specified key must be in PEM format
|
||||
- **`ssl_cert`** - Defines a path to the X509 certificate file to use for TLS. This option requires that you use the absolute path, not a relative path. The X609 certificate must be in PEM format.
|
||||
- **`ssl_ca`** - Defines a path to a PEM file that should contain one or more X509 certificates for trusted Certificate Authorities (CAs) to use for TLS. This option requires that you use the absolute path, not a relative path.
|
||||
- **`ssl_capath`** - Defines a path to a directory that contains one or more PEM files that contains one X509 certificate for a trusted Certificate Authority (CA)
|
||||
- **`ssl_cipher`** - Defines a list of permitted cipher suites to use for TLS
|
||||
- **`ssl_crlpath`** - Defines a path to a PEM file that should contain one or more revoked X509 certificates to use for TLS. This option requires that you use the absolute path, not a relative path.
|
||||
- **`ssl_verify_cert`** - Enables server certificate verification.
|
||||
- **`ssl`** - The connection must use TLS security, or it will fail.
|
||||
- **`tls_version`** - A comma-separated list (without whitespaces) of TLS versions. Valid versions are TLSv1.0, TLSv1.1,TLSv1.2 and TLSv1.3. Added in version 1.1.7.
|
||||
- **`autocommit`** (default: `False`) - Specifies the autocommit settings. True will enable autocommit, False will disable it (default).
|
||||
- **`converter`** - Specifies a conversion dictionary, where keys are FIELD_TYPE values and values are conversion functions
|
||||
|
||||
"""
|
||||
if kwargs:
|
||||
|
@ -31,32 +31,18 @@ class ConnectionPool(object):
|
||||
Class defining a pool of database connections
|
||||
|
||||
MariaDB Connector/Python supports simple connection pooling.
|
||||
A connection pool holds a number of open connections and handles
|
||||
thread safety when providing connections to threads.
|
||||
A connection pool holds a number of open connections and handles thread safety when providing connections to threads.
|
||||
|
||||
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.
|
||||
The size of a connection pool is configurable at creation time, but cannot be changed afterward. The maximum size of a connection pool is limited to 64 connections.
|
||||
|
||||
Keyword Arguments:
|
||||
|
||||
* pool_name (str) -- Name of connection pool
|
||||
- **`pool_name`** (``str``) - Name of connection pool
|
||||
- **`pool_size`** (``int``) - Size of pool. The Maximum allowed number is 64. Default to 5
|
||||
- **`pool_reset_connection`** (``bool``) - Will reset the connection before returning it to the pool. Default to True.
|
||||
- **`pool_validation_interval`** (``int``) - Specifies the validation interval in milliseconds after which the status of a connection requested from the pool is checked. A value of 0 means that the status will always be checked. Default to 500 (Added in version 1.1.6)
|
||||
- **\*\*kwargs** - Optional additional connection arguments, as described in mariadb.connect() method.
|
||||
|
||||
* 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.
|
||||
|
||||
* pool_validation_interval (int)=500 -- Specifies the validation
|
||||
interval in milliseconds after which the status of a connection
|
||||
requested from the pool is checked.
|
||||
The default value is 500 milliseconds, a value of 0 means that
|
||||
the status will always be checked.
|
||||
(Added in version 1.1.6)
|
||||
|
||||
* **kwargs: Optional additional connection arguments, as described in
|
||||
mariadb.connect() method.
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@ -67,12 +53,12 @@ class ConnectionPool(object):
|
||||
Name of connection pool
|
||||
|
||||
:param int pool_size:
|
||||
Size of pool. If not specified default value of 5 will be used.
|
||||
Maximum allowed number is 64.
|
||||
Size of pool. If not specified, the default value of 5 will be used.
|
||||
The Maximum allowed number is 64.
|
||||
|
||||
:param bool pool_reset_connection:
|
||||
Will reset the connection before returning it to the pool.
|
||||
Default value is True.
|
||||
The Default value is True.
|
||||
|
||||
:param **kwargs kwargs:
|
||||
Optional additional connection arguments, as described in
|
||||
@ -170,7 +156,7 @@ class ConnectionPool(object):
|
||||
"""
|
||||
Adds a connection object to the connection pool.
|
||||
|
||||
In case that the pool doesn’t have a free slot or is not configured
|
||||
In case that the pool doesn’t have a free slot or is not configured,
|
||||
a PoolError exception will be raised.
|
||||
"""
|
||||
|
||||
@ -256,10 +242,10 @@ class ConnectionPool(object):
|
||||
def set_config(self, **kwargs):
|
||||
"""
|
||||
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.
|
||||
|
||||
Note: This method doesn't create connections in the pool.
|
||||
To fill the pool one has to use add_connection() ḿethod.
|
||||
To fill the pool, one has to use add_connection() ḿethod.
|
||||
"""
|
||||
|
||||
self._conn_args = kwargs
|
||||
|
@ -90,50 +90,22 @@ class Connection(mariadb._mariadb.connection):
|
||||
"""
|
||||
Returns a new cursor object for the current connection.
|
||||
|
||||
If no cursorclass was specified, a cursor with default mariadb.Cursor
|
||||
class will be created.
|
||||
If no cursorclass was specified, a cursor with default mariadb.Cursor class will be created.
|
||||
|
||||
Optional keyword parameters:
|
||||
|
||||
- buffered = True
|
||||
If set to False the result will be unbuffered, which means before
|
||||
executing another statement with the same connection the entire
|
||||
result set must be fetched.
|
||||
Please note that the default was False for MariaDB Connector/Python
|
||||
versions < 1.1.0.
|
||||
- **buffered** (default: ``True``) - If disabled, the result will be unbuffered, which means before executing another statement with the same connection, the entire result set must be fetched. Please note that the default was False for MariaDB Connector/Python versions < 1.1.0.
|
||||
- **dictionary** (default: ``False``) - Return fetch values as dictionary when enabled.
|
||||
- **named_tuple** (default: ``False``) - Return fetch values as named tuple. This feature exists for compatibility reasons and should be avoided due to possible inconsistency.
|
||||
- **cursor_type** (default: ``CURSOR.NONE``) - If cursor_type is set to CURSOR.READ_ONLY, a cursor is opened for the statement invoked with cursors execute() method.
|
||||
- **prepared** (default: ``False``) - When enabled, the cursor will remain in prepared state after the first execute() method was called. Further calls to execute() method will ignore the SQL statement.
|
||||
- **binary** (default: ``False``) - Always execute statement in MariaDB client/server binary protocol.
|
||||
|
||||
- dictionary = False
|
||||
Return fetch values as dictionary.
|
||||
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.
|
||||
|
||||
- named_tuple = False
|
||||
Return fetch values as named tuple. This feature exists for
|
||||
compatibility reasons and should be avoided due to possible
|
||||
inconsistency.
|
||||
fetch* methods of the cursor class by default return result set values as a tuple, unless dictionary or named_tuple was specified. The latter one exists 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.
|
||||
|
||||
- cursor_type = CURSOR.NONE
|
||||
If cursor_type is set to CURSOR.READ_ONLY, a cursor is opened
|
||||
for the statement invoked with cursors execute() method.
|
||||
|
||||
- prepared = False
|
||||
When set to True cursor will remain in prepared state after the first
|
||||
execute() method was called. Further calls to execute() method will
|
||||
ignore the sql statement.
|
||||
|
||||
- binary = False
|
||||
Always execute statement in MariaDB client/server binary protocol.
|
||||
|
||||
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.
|
||||
|
||||
fetch* methods of the cursor class by default return result set values
|
||||
as a tuple, unless dictionary or named_tuple was specified.
|
||||
The latter one exists 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.
|
||||
|
||||
If cursor_type is set to CURSOR.READ_ONLY, a cursor is opened for
|
||||
the statement invoked with cursors execute() method.
|
||||
If cursor_type is set to CURSOR.READ_ONLY, a cursor is opened for the statement invoked with cursors execute() method.
|
||||
"""
|
||||
self._check_closed()
|
||||
cursor = cursorclass(self, **kwargs)
|
||||
@ -196,7 +168,7 @@ class Connection(mariadb._mariadb.connection):
|
||||
This function is used to ask the server to kill a database connection
|
||||
specified by the processid parameter.
|
||||
|
||||
The connection id can be be retrieved by SHOW PROCESSLIST sql command.
|
||||
The connection id can be retrieved by `SHOW PROCESSLIST` SQL command.
|
||||
"""
|
||||
|
||||
self._check_closed()
|
||||
@ -209,7 +181,7 @@ class Connection(mariadb._mariadb.connection):
|
||||
def begin(self):
|
||||
"""
|
||||
Start a new transaction which can be committed by .commit() method,
|
||||
or cancelled by .rollback() method.
|
||||
or canceled by .rollback() method.
|
||||
"""
|
||||
self._check_closed()
|
||||
self._execute_command("BEGIN")
|
||||
@ -258,7 +230,7 @@ class Connection(mariadb._mariadb.connection):
|
||||
|
||||
Parameters:
|
||||
|
||||
- format_id: Format id. If not set default value `0` will be used.
|
||||
- format_id: Format id. Default to value `0`.
|
||||
|
||||
- global_transaction_id: Global transaction qualifier, which must be
|
||||
unique. The maximum length of the global transaction id is
|
||||
@ -302,11 +274,11 @@ class Connection(mariadb._mariadb.connection):
|
||||
|
||||
Begins a TPC transaction with the given transaction ID xid.
|
||||
|
||||
This method should be called outside of a transaction
|
||||
(i.e. nothing may have executed since the last .commit()
|
||||
This method should be called outside a transaction
|
||||
(i.e., nothing may have been executed since the last .commit()
|
||||
or .rollback()).
|
||||
Furthermore, it is an error to call .commit() or .rollback() within
|
||||
the TPC transaction. A ProgrammingError is raised, if the application
|
||||
the TPC transaction. A ProgrammingError is raised if the application
|
||||
calls .commit() or .rollback() during an active TPC transaction.
|
||||
"""
|
||||
|
||||
@ -325,8 +297,10 @@ class Connection(mariadb._mariadb.connection):
|
||||
|
||||
def tpc_commit(self, xid=None):
|
||||
"""
|
||||
Optional parameter:"
|
||||
xid: xid object which was created by .xid() method of connection class.
|
||||
Optional parameter:
|
||||
|
||||
- xid
|
||||
: xid object which was created by .xid() method of connection class.
|
||||
|
||||
When called with no arguments, .tpc_commit() commits a TPC transaction
|
||||
previously prepared with .tpc_prepare().
|
||||
@ -337,8 +311,8 @@ class Connection(mariadb._mariadb.connection):
|
||||
When called with a transaction ID xid, the database commits the given
|
||||
transaction. If an invalid transaction ID is provided,
|
||||
a ProgrammingError will be raised.
|
||||
This form should be called outside of a transaction, and
|
||||
is intended for use in recovery."
|
||||
This form should be called outside a transaction, and
|
||||
is intended for use in recovery.
|
||||
"""
|
||||
|
||||
self._check_closed()
|
||||
@ -381,7 +355,7 @@ class Connection(mariadb._mariadb.connection):
|
||||
def tpc_prepare(self):
|
||||
"""
|
||||
Performs the first phase of a transaction started with .tpc_begin().
|
||||
A ProgrammingError will be raised if this method was called outside of
|
||||
A ProgrammingError will be raised if this method was called outside
|
||||
a TPC transaction.
|
||||
|
||||
After calling .tpc_prepare(), no statements can be executed until
|
||||
@ -423,7 +397,7 @@ class Connection(mariadb._mariadb.connection):
|
||||
class
|
||||
|
||||
Performs the first phase of a transaction started with .tpc_begin().
|
||||
A ProgrammingError will be raised if this method outside of a TPC
|
||||
A ProgrammingError will be raised if this method outside a TPC
|
||||
transaction.
|
||||
|
||||
After calling .tpc_prepare(), no statements can be executed until
|
||||
@ -488,7 +462,7 @@ class Connection(mariadb._mariadb.connection):
|
||||
|
||||
@property
|
||||
def database(self):
|
||||
"""Get default database for connection."""
|
||||
"""Get the current database of the connection."""
|
||||
|
||||
self._check_closed()
|
||||
return self._mariadb_get_info(INFO.SCHEMA)
|
||||
@ -507,8 +481,8 @@ class Connection(mariadb._mariadb.connection):
|
||||
@property
|
||||
def user(self):
|
||||
"""
|
||||
Returns the user name for the current connection or empty
|
||||
string if it can't be determined, e.g. when using socket
|
||||
Returns the username for the current connection or empty
|
||||
string if it can't be determined, e.g., when using socket
|
||||
authentication.
|
||||
"""
|
||||
self._check_closed()
|
||||
@ -520,7 +494,7 @@ class Connection(mariadb._mariadb.connection):
|
||||
"""
|
||||
Client character set.
|
||||
|
||||
For MariaDB Connector/Python it is always utf8mb4.
|
||||
For MariaDB Connector/Python, it is always utf8mb4.
|
||||
"""
|
||||
|
||||
return _DEFAULT_CHARSET
|
||||
@ -552,7 +526,7 @@ class Connection(mariadb._mariadb.connection):
|
||||
@property
|
||||
def server_port(self):
|
||||
"""
|
||||
Database server TCP/IP port. This value will be 0 in case of a unix
|
||||
Database server TCP/IP port. This value will be 0 in case of an unix
|
||||
socket connection.
|
||||
"""
|
||||
|
||||
@ -656,10 +630,10 @@ class Connection(mariadb._mariadb.connection):
|
||||
Toggles autocommit mode on or off for the current database connection.
|
||||
|
||||
Autocommit mode only affects operations on transactional table types.
|
||||
Be aware that rollback() will not work, if autocommit mode was switched
|
||||
Be aware that rollback() will not work if autocommit mode was switched
|
||||
on.
|
||||
|
||||
By default autocommit mode is set to False."
|
||||
By default, autocommit mode is set to False.
|
||||
"""
|
||||
|
||||
self._check_closed()
|
||||
@ -693,9 +667,9 @@ class Connection(mariadb._mariadb.connection):
|
||||
"""
|
||||
Returns true if the connection is alive.
|
||||
|
||||
A ping command will be send to the server for this purpose,
|
||||
A ping command will be sent to the server for this purpose,
|
||||
which means this function might fail if there are still
|
||||
non processed pending result sets.
|
||||
non-processed pending result sets.
|
||||
"""
|
||||
|
||||
self._check_closed()
|
||||
|
Reference in New Issue
Block a user