[CONPY-87] Error with numeric values returned from query. Created: 2020-07-16 Updated: 2020-07-17 Resolved: 2020-07-17 |
|
| Status: | Closed |
| Project: | MariaDB Connector/Python |
| Component/s: | Generic |
| Affects Version/s: | 1.0.0 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Michal Sarna | Assignee: | Georg Richter |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
Mac OS X 10.15.5 Python Version: In DB data looks like:
-----------
----------- In script returns values like: but when run like this: returns proper values: Server is MariaDB 10 on Synology. |
| Comments |
| Comment by Georg Richter [ 2020-07-16 ] | |||||||||||||||||||
|
Hi, thank you for your bug report. Did you read https://mariadb.com/kb/en/floating-point-accuracy/ ? | |||||||||||||||||||
| Comment by Michal Sarna [ 2020-07-17 ] | |||||||||||||||||||
|
Hi. | |||||||||||||||||||
| Comment by Georg Richter [ 2020-07-17 ] | |||||||||||||||||||
|
You will get only correct values, if it is converted to Decimal, so the corresponding datatype needs to be decimal instead of float or double:
or with a cursor:
| |||||||||||||||||||
| Comment by Michal Sarna [ 2020-07-17 ] | |||||||||||||||||||
|
Ok ... and where precisely in my script is any type of multiplication ? | |||||||||||||||||||
| Comment by Georg Richter [ 2020-07-17 ] | |||||||||||||||||||
|
The multiplication should just show you that float is not accurate and the use of FLOAT should be avoided, as mentionen in MariaDB documentation: "Using FLOAT might give you some unexpected problems because all calculations in MariaDB are done with double precision" The difference in output with and without placeholder is that one uses binary protocol (transferring float as 4-byte binary) and the other uses text protocol. | |||||||||||||||||||
| Comment by Michal Sarna [ 2020-07-17 ] | |||||||||||||||||||
|
OK. I've get it. Changed in DB from float double. Thx for Your time. |