In case of an (automatic) reconnect the connection property
connection_id was not updated, since there is no callback
functionality in Connector/C available to notify the application
that a reconnect occured. Instead of obtaining the connection_id
via MemberDef, connection_id is now implemented as getter function.
Methods which are defined via PyMemberDef with flag METH_VARARGS
and have only one parameter are using METH_O now: Instead of parsing
and converting parameter via PyArgs_ParseTuple we now check the type
and convert passed python object directly to the corresponding c type.
Similiar to description property, this property returns
a dictionary with complete metadata.
The dictionary contains the following keys:
- catalog: catalog (always 'def')
- schema: current schema
- field: alias column name or if no alias was specified
column name
- org_field: original column name
- table: alias table name or if no alias was specified
table name
- org_table: original table name
- type: column type
- charset: character set (utf8mb4 or binary)
- length: The length of the column
- max length: The maximum length of the column
- decimals: The numer of decimals
- flags: Flags (flags are defined in constants.FIELD_FLAG)
- ext_type: Extended data type (types are defined in
constants.EXT_FIELD_TYPE)
This fixes also CONPY-270: Instead of checking BINARY_FLAG we now
check character set for binary object types.
Replaced collections.named_tuple by C-Pythons PyStruct_Sequence.
All conversion are done now before fetching a row: converting to
other result types than tuple (named tuple or dict) now have less
overhead and are significantly faster.
Display status of connection, cursor and pool class in
string representation.
If an object (cursor, class, connection pool) was closed, the
string representation (tp_repr) now shows the status of the object.
Example:
>>> import mariadb
>>> connection=mariadb.connect()
>>> connection
<mariadb.connection connected to 'localhost' at 0x7f94d77c3b40>
>>> connection.close()
>>> connection
<mariadb.connection (closed) at 0x7f94d77c3b40>
The following attributes were added:
1) mariadb.client_version
Returns the version of MariaDB Connector/C library as an integer
2) mariadb.client_version_info
Returns the version of MariaDB Connector/C library as tuple
Added connection attribute server_version_info and (for compatibiliry)
get_server_version() method.
Both return a tuple, describing the version number of connected server
in following format: (MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION)
Changed sequence description from Row to mariadb.Row.
This patch also includes a followup fix for CONP-131:
PyStrustSequenceNew will be used only for Python versions > 3.6
Connection attributes in PyMember definition will be accessed as
string constants instead of Python Object, so the object will be
created only if the member will be accessed in python code and it's
reference count doesn't need to be decrement when the connection
class will be deallocated.
Instead of OperationalException and IntegrityException will be raised
for the following eror types:
ER_BAD_NULL_ERROR, ER_DATA_OUT_OF_RANGE, ER_CONSTRAINT_FAILED, ER_DUP_CONSTRAINT_NAME
When creating a cursor with result set type named_tuple
or dictionary, references were not decremented correctly.
For named tuples we don't use a static variable anymore, instead
of it will be created by PyStructSequence_NewType.
The connect() method now accepts an addtional parameter
converter which points to a dictionary, containing one or more conversions.
A conversion must be specified in the form {FIELD_TYOE : conversion_function}
Beginning of MariaDB 10.5 metadata for JSON columns is stored
in extended field information, and the reported type is MYSQL_TYPE_BLOB.
We now check extended field information to return correct type and for
fetching values in correct format.
Add option binary for cursor. When set to true cursor will always try
to use the client/server binary protocol, even when no parameter were
passed to execute.
Added optional boolean parameter 'dictionary' for cursor class.
When dictionary parameter was set to true, the fetch operations will
return rows from result set as Dict.
1) When retrieving data with column type MYSQL_TYPE_NEWDECIMAL C/Python
now loads the decimal module and converts data from string into Pythons
decimal.Decimal type.
2) Wnen sending a decimal.Decimal parameter, value will be converted to string
and send with type MYSQL_TYPE_NEWDECIMAL to server.
When using a buffered cursor, we need to store the field_count inside
Mrdb_Cursor, since db.commit/rollback will overwrite/clear mysql->field_count
inside Connector/C.
When converting time or datetime values with microseconds, the
calculation was wrong, e.g. a millisecond value of .123 was converted
to .000123 instead of .123000. This was already fixed in C/C but not
in C/Python.