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.
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.
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.
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.
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.
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.
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
- 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
- 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
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.