[CONPY-271] cursor metadata property Created: 2023-10-04  Updated: 2023-10-11  Resolved: 2023-10-11

Status: Closed
Project: MariaDB Connector/Python
Component/s: Other
Affects Version/s: N/A
Fix Version/s: 1.1.8

Type: New Feature Priority: Major
Reporter: Georg Richter Assignee: Georg Richter
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks CONPY-270 string coercion not applied to UUID w... Closed
Python Version: 3.8+

 Description   

The cursor description as defined in PEP-249 doesn't cover all metadata provided from MariaDB server.

Instead of extending description cursor should provide a new property 'metadata', which returns all metadata information as a dictionary.

Example:

import mariadb
 
conn=mariadb.connect(user="root", db="test")
cursor=conn.cursor()
 
cursor.execute("create or replace table t1 (a json, b text, c uuid, d int)")
cursor.execute("select * from t1")
print(cursor.metadata)

Output:

{'catalog': ('def', 'def', 'def', 'def'), 'schema': ('test', 'test', 'test', 'test'), 'field': ('a', 'b', 'c', 'd'), 'org_field': ('a', 'b', 'c', 'd'), 'table': ('t1', 't1', 't1', 't1'), 'org_table': ('t1', 't1', 't1', 't1'), 'type': (252, 252, 254, 3), 'charset': (45, 45, 45, 63), 'length': (4294967295, 262140, 144, 11), 'max_length': (0, 0, 0, 0), 'decimals': (0, 0, 0, 0), 'flags': (144, 16, 160, 32768), 'ext_type_or_format': (1, 0, 2, 0)}

ext_type_or_format values will be defined in constants/EXT_FIELD_TYPE.py:

NONE =0
JSON = 1
UUID = 2
INET4 = 3
INET6 = 4
POINT = 5
MULTIPOINT = 6
LINESTRING = 7
MULTILINESTRING = 8
POLYGON = 9
MULTIPOLYGON = 10
GEOMETRYCOLLECTION = 11


Generated at Thu Feb 08 03:31:31 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.