Commit Graph

89 Commits

Author SHA1 Message Date
7c2134dddb Fix for CONPY-278:
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.
2024-01-31 17:21:48 +01:00
28827984bd CONPY-280:
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.
2024-01-31 15:15:49 +01:00
9952ff09af CONPY-276:
Allow to retrieve data from buffered cursor if the connection
was already closed.
2023-12-20 17:29:28 +01:00
cfe1d10702 CONPY-271: Added cursor.metadata property
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.
2023-10-11 14:50:23 +02:00
b0366fa108 Performance fix:
Rewrote parameter type checks for text protocol in cpython.
2023-04-17 09:51:41 +02:00
ce228b68da CONPY-227: Replace collections.named_tuple
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.
2022-10-10 09:01:19 +02:00
a9ad1fcaee First implementation for status callback 2022-08-05 14:41:43 +02:00
9b8a32dad6 Build fixes:
This patch includes fixes for building with Python 3.11 (see
CONPY-201):

- PyType assignments replaced by Py_SET_TYPE
- removed orphaned doc strings
2022-05-10 09:06:56 +02:00
a839827f59 CONPY-189: Windows build fix for Visual Studio 2022
- Build parameters are now written to config_win.h instead of passing
  them as command line parameters
- Fixed several compiler warnings
2021-12-21 08:21:04 +01:00
263f428213 CONPY-184
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>
2021-12-13 05:55:10 +01:00
a366bbaf19 Windows build fix 2021-10-18 12:42:44 +02:00
7f469a3f26 CONPY-161:
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
2021-08-22 11:19:05 +02:00
2e7dcde73b Removed converter from C Code 2021-08-16 10:41:07 +02:00
307046ba6f Removed unused MemberDefs from connection 2021-08-16 10:12:41 +02:00
47ca11d921 Documentation update 2021-08-01 10:31:10 +02:00
5a81686f4c Documentation work 2021-07-26 06:54:38 +02:00
ea97f66769 connection class:
moved kill method to python class
2021-07-22 16:06:27 +02:00
2bd40ca1de Test fixes 2021-07-18 18:16:38 +02:00
8ee02ac7e3 Cursor fixes for execute, implemented execute_direct 2021-07-14 22:14:52 +02:00
84df56ce40 connection and cursor class are now written in
native python
2021-07-12 09:46:05 +02:00
aa65cc853a Exchanged C written connection pool class by native python class. 2021-01-18 06:11:03 +01:00
7df428ecf8 Moved Objects from c to python code
Indicator, BINARY, NUMBER, STRING and DATE objects were moved
to python code
2020-11-30 16:49:16 +01:00
a1c709b0e8 Fix for CONPY-133:
Extended parser for supporting MariaDB comment syntax
(https://mariadb.com/kb/en/comment-syntax/)
2020-11-24 14:00:56 +01:00
312ba15173 Follow up of fix for CONC-130:
Workaround for #21066 (https://bugs.python.org/issue20066)
2020-11-16 14:58:59 +01:00
a47d3e5d76 Implementation of CONPY-129:
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)
2020-11-16 10:03:05 +01:00
4a5d02a1b1 Fix for CONPY-130: DeprecationWarning: builtin type Row has no _module_ attribute
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
2020-11-16 07:33:53 +01:00
f6be6ba512 Fix for CONPY-131:
Instead of using PyStructSequence_New (broken in Python3.6) use a
static struct which will be initialized voa PyStructSequence_Init()
call.
2020-11-16 07:07:50 +01:00
37864dd831 Fix for CONPY-126
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.
2020-11-01 09:14:11 +01:00
3b2edf5b35 Fix for CONPY-115:
Replaced the obsolete ULONG_LONG_MAX definition by
ULLONG_MAX.
2020-10-19 08:11:32 +02:00
8944cb889a Error handling fixes:
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
2020-10-04 11:35:40 +02:00
846c0d0fdb Fix for CONPY-119: Fixed memory leak
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.
2020-10-03 16:41:29 +02:00
bce98d74cd Fix for CONPY-118: Leak when using text protocol
Removed statement allocation from the cursor init function and
allocate it only in executemany and execute if paraemters were
supplied.
2020-10-02 12:52:09 +02:00
08673bbdf4 Small "workaround" for MDEV-23481:
Don't set the unsigned flag if the value will fit into signed integer.
2020-09-29 14:14:02 +02:00
3f95456824 CONPY-117: Added converter support
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}
2020-09-29 13:21:13 +02:00
5d4a8d5d62 Fix for CONPY-116: Wrong type reported for SQL type JSON
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.
2020-09-29 11:43:47 +02:00
709ac83799 Fixed compiler warnings 2020-09-19 14:05:53 +02:00
bd560c2bb9 Fix for CONPY-108 (memory leak):
- initialize datetime API only once per object file
- don't reparse same statement
2020-08-29 12:20:52 +02:00
e091edd549 Fix for CONPY-106
Check error number instead of SQL code for determine exception type.
2020-08-14 14:44:05 +02:00
588bc01cc0 Implementation for CONPY-100:
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.
2020-08-12 16:05:29 +02:00
01053e0d4a Fix for CONPY-93:
When releasing the GIL we need to unblock/block in callback functions (mariadb_codecs.c)
2020-08-05 18:54:19 +02:00
ea8354bb8b Added internal members for client and server capabilities to
MrdbConnection class.
2020-06-18 10:23:56 +02:00
5631d6ed3f Fixed bug in pooling tests:
Paraneters in set_config() method have to be checked against the list of DSN keywords.
2020-06-17 08:59:31 +02:00
ed2695b68c Fix for CONPY-78:
Instead of checking the server version number if a specific feature
is supported, we need to check the server capability or extended
capability flag.
2020-06-15 10:13:26 +02:00
e58caef84c Fix for CONPY-67:
If no rows were fetched from an unbuffered cursor (resultset) rowcount
now returns -1 instead of 0.
2020-05-27 10:40:35 +02:00
7142bedc62 Fix for CONPY-66:
fixed typo in setup configuration for windows, which caused to link
dynamically against MySQL Connector/C.
2020-05-14 14:24:32 +02:00
e873f87fab CONPY-56: Support dictionary option in cursor class
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.
2020-04-14 06:25:25 +02:00
eb46aa83ba Windows build fix for __attribute__((unused)):
Undefine __attribute__() macro if compiler is not gnuc or clang.
2020-04-06 20:26:05 +02:00
fe95eb0dee CONPY-49: Added support for Decimal type
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.
2020-04-05 22:01:17 +02:00
a992bf3568 Fix for CONPY-51:
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.
2020-04-05 21:45:44 +02:00
083086b1dd Fix for CONPY-45:
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.
2020-03-25 18:11:02 +01:00