Commit Graph

66 Commits

Author SHA1 Message Date
40690c45fc Test fix:
Check server version for INET4/INET6 usage
2025-02-13 10:46:07 +01:00
befe7000c9 Follow up for CONPY-299
- Added byteswap function for vector (bigendian)
- Use buffer protocol instead of calling array's
  methods
2025-02-10 13:59:43 +01:00
7cfc325feb CONPY-295: Fix unsigned check
Fixed check for signed/unsigned integers when sending parameters
via executemany().
2025-01-30 09:20:57 +01:00
138a02238e CONPY-299: support for VECTOR data type
Implemented support for VECTOR paramter. Beside text representation
(Vec_FromText) or array to byte conversion (array.tobytes) it is now
possible to specify an float array as parameter.

Example:

import mariadb, array

...

sql = """
  CREATE OR REPLACE TABLE test(
     id INT PRIMARY KEY,
     v VECTOR(3) NOT NULL,
      VECTOR INDEX (v))")"""

cursor.execute(sql)

vector= array.array('f', [123.1, 230.9, 981.7])

cursor.execute("INSERT INTO test VALUES (?,?)", (1, vector))

Please note that the opposite way, retrieving a float array is not
supported yet. This will require either a new or extended field
type for vector data type.
2025-01-30 09:02:07 +01:00
f96cbe2759 Travis build fixes:
- Skip MySQL batch tests
- Fix travis on windows
2024-10-01 15:55:33 +02:00
c9c0278950 Travis fixes:
- skip extended field types for MaxScale
- remove shadowed test
2024-09-28 08:17:49 +02:00
5ae028e153 CONPY-289: BIGINT out of range on bulk insert
If a bigint value is > LONGLONG_MAX it must be
indicated that it is an unsigned value
(param->is_unsigned= 1).
2024-09-27 17:14:25 +02:00
afb3ccd778 Check return code of db_generate_bulk_request
When inserting data via parameter callback function, an error
will be raised.
2024-09-14 15:31:57 +02:00
e705d637ea Fix CONPY-283: Incorrect result format after cursor.scroll()
Since unsigned long is 32-bit under windows, row_number must
be defined as uint64_t, since we assign 64-bit values directly
from python code.
2024-03-18 10:03:57 +01:00
d672551c7d Fix for CONPY-277:
To avoid a syntax error when running under sql_mode ANSI_QUOTES
parameter substitution will be done by using single quotes instead
of double quotes.
2024-02-05 07:02:39 +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
5a3dd3da6b [misc] test correction 2023-12-15 14:53:14 +01:00
76a766141f [misc] test stability improvement for mysql server 2023-12-14 16:35:23 +01:00
ba6b6e9255 [misc] correct CREATE OR REPLACE commands to DROP IF EXISTS + CREATE for mysql test compatibility 2023-12-14 10:55:10 +01:00
1762e9d458 Travis: Added Python-3.12 2023-10-12 06:01:00 +02:00
84e423295a Test fix
Skip extended field type test if server is MySQL
or MariaDB server version is < 10.10
2023-10-12 05:41:40 +02: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
05f4cede96 Fix typo 2023-09-30 17:40:00 +02:00
91ecc9e3bf Workaround for CONPY-269:
Even if PEP-249 permits operations on a closed cursor, we don't
raise an exception if the cursor or the underlying connection
was closed. Instead rowcount property will return -1.

This is a workaround for pandas, where rowcount will be checked
after the cursor was closed.
2023-09-29 10:34:30 +02:00
6afeaa53d1 CONPY-258: Fixed ValueError exception if ZEROFILL flag is defined
For backwards compatibility PyLong_FromString interprets leading
zeros as octal value which will end up in a value error, if the
number contains 2 or more leading zeros.
2023-04-06 17:22:26 +02:00
0c844879fd Fix for CONPY-251
Check if stmt was already initialized in cursor method
nextset().
2023-02-12 08:26:37 +01:00
d70be504e3 Fix for CONPY-225:
Set value for affected_rows.
2022-10-07 08:47:48 +02:00
37ea27cf86 Fix for CONPY-224:
If a bulk operation is executed and the statement doesn't need to
be reprepared, only array size has to be updated, since setting
the number of parameters (STMT_ATTR_PREBIND_PARAMS) will reset the
statement in Connector/C.
2022-09-22 07:26:46 +02:00
215d983df0 Fixed test name:
Last commit message was incorrect, issue fixed CONPY-222, not
CONPY-221 (which was already closed).
2022-08-27 07:39:50 +02:00
c3fe1a954e Fix for CONPY-221:
Removed __del__ method from cursors.py to prevent
raisiing if cursor was already properly closed via close()
method.
2022-08-27 07:25:09 +02:00
cdd42743cc Coding style fixes (PEP8)
Fixed various coding style stuff detected by flake8.
Added .pre-commit-config.yaml:
With command pre_commit install a hook for flake8 will be
installed.
2022-08-07 16:47:26 +02:00
205b9c2768 CONPY-218: Allow None as data parameter
Allow None as data parameter for cursors execute()
method.
Kudos to  Luciano Barcaro for providing a fix.
2022-07-21 05:46:53 +02:00
c30b597ba9 Fix for CONPY-213
Additionally to the fix for CONPY-214 (which fixed the iterator), we
need to check that converter will not be called with EOF (None).
2022-07-07 13:42:34 +02:00
275aaf3ee1 Fix for CONPY-214:
Replace cursor iterator by native python __iter__() method.
2022-07-06 22:57:58 +02:00
09e5cad2c0 Fix for CONPY-212
The default settiing for buffered in cursors.execute() method has
to be None:
- if not specified, it will use cursor defaults
- if specified, the default behavior of cursor will be changed
2022-06-29 15:09:20 +02:00
ba56c73a34 CONPY-209:
When executing cursor in text protocol, the substitution of
parameters with mb chars didn't set the correct length.
2022-06-29 12:29:38 +02:00
1b78f22a3c test fixes 2022-06-27 19:42:43 +02:00
5420fe39d9 Various fixes:
- removed utf8 part of parser, instead we use python binary
  object for parameter substituton (text mode)
- removed memory leaks
- fixed crash when reusing cursor with different number of
  placeholders
2022-06-08 13:43:20 +02:00
f23e4e9b83 CONPY-205: Added error constants
Error code constants are now defined in constants/ERR.
The file ERR.py is generated by helper/create_errconst.py
script, please don't edit it.
2022-05-25 18:54:11 +02:00
30c8f33b08 CONPY-205: Inconsistent exceptions
- All parameter exceptions are now ProgrammingErrors
- A dictionary now might contain more keys than
  placeholders in statement
- Fixed unhandled exception when using dictionary as parameter
2022-05-25 18:47:03 +02:00
0a7f751f68 Test fixes 2022-05-21 10:06:26 +02:00
f2fc6e8af6 test for CONPY-178 2022-03-25 06:30:23 +01:00
2e81925a3e Skip test if we are connected to MySQL server 2022-02-20 14:34:51 +01:00
ba1bce8b62 Added test for REPLACE RETURNING 2022-02-20 08:56:21 +01:00
f844622b51 Added test for CONPY-194 2022-02-20 05:03:43 +01:00
811cc1c5f7 Check if object was closed:
When accessing methods or properties of connection and cursor objects
we now check if the object or parent object was closed and raise an
exception.
2022-01-16 20:59:58 +01:00
db3b6f555c test - change travis test to use common framework in order to set different server type
update benchmarks
2021-12-17 15:05:04 +01:00
3184707494 Fix for CONPY-168
Force use of binary protocol if binary parameters
were provided.
2021-10-03 06:50:00 +02:00
0074295d75 Parser:
Added unicode support for statement parser
2021-10-02 15:52:42 +02:00
cfe3eee3b4 Fix for CONPY-167:
If executemany() is executed directly after execute() with the same
statement it needs to be reprepared.
2021-09-25 12:50:12 +02:00
1ab9f833bf Test fix:
When connected against MySQL or MariaDB < 10.2 server
we need to skip tests which use INDICATOR variables,
since they can't be used in mysql_stmt_execute() C API
function.
2021-08-16 09:32:32 +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
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
35a12359b5 travis: disable bench 2020-11-23 09:31:20 +01:00