[CONPY-50] Convert Decimal to non native Decimal type Created: 2020-04-02  Updated: 2020-04-02  Resolved: 2020-04-02

Status: Closed
Project: MariaDB Connector/Python
Component/s: Generic
Affects Version/s: 0.9.55
Fix Version/s: 0.9.56, N/A

Type: Bug Priority: Major
Reporter: Georg Richter Assignee: Georg Richter
Resolution: Duplicate Votes: 0
Labels: None


 Description   

In current implemenation of MariaDB Connector/C MYSQL_TYPE_NEWDECIMAL is converted into a string in both text and binary protocol.

For compatibility reasons it should be converted to (non native) Decimal type, which will require an additional import of the decimal module.

How to repeat:

MariaDB [testp] CREATE TEMPORARY TABLE t1 (a decimal 10,2);
MariaDB [testp] INSERT INTO t1 VALUES(27);

Python:

conn= mariadb.connect(user="georg")
cursor=conn.cusor()
cursor.execute("SELECT a FROM t1")
cursor.fetchone()

Output:

MariaDB Connector/Python: '27.00'
other PEP-249 modules: Decimal('27.00')

The example above only shows Decimal usage in result set, it needs to be supported also in parameters for execute() and executemany()



 Comments   
Comment by Georg Richter [ 2020-04-02 ]

Duplicate of CONPY-49.

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