Micha Koller
unread,Jan 6, 2012, 12:47:05 PM1/6/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to PyMySQL Users
Hello,
I'm using PyMySQL3-0.4 with Python 3.2 under Ubuntu Linux and Eclipse.
If a query should give back a decimal result the error message "Cannot
convert %r to Decimal" % value" appears.
What can I do?
Micha
Minimal pyhton example to reproduce:
import pymysql
conn = pymysql.connect(host= "localhost", user="root", passwd="root",
db="xyz")
dbCursor = conn.cursor ()
query ="SELECT 1.0"
dbCursor.execute (query)
Full error message:
Traceback (most recent call last):
File "/home/mk/.local/lib/python3.2/site-packages/pymysql/
cursors.py", line 103, in execute
result = self._query(query)
File "/home/mk/.local/lib/python3.2/site-packages/pymysql/
cursors.py", line 221, in _query
conn.query(q)
File "/home/mk/.local/lib/python3.2/site-packages/pymysql/
connections.py", line 599, in query
self._affected_rows = self._read_query_result()
File "/home/mk/.local/lib/python3.2/site-packages/pymysql/
connections.py", line 685, in _read_query_result
result.read()
File "/home/mk/.local/lib/python3.2/site-packages/pymysql/
connections.py", line 873, in read
self._read_result_packet()
File "/home/mk/.local/lib/python3.2/site-packages/pymysql/
connections.py", line 886, in _read_result_packet
self._read_rowdata_packet()
File "/home/mk/.local/lib/python3.2/site-packages/pymysql/
connections.py", line 911, in _read_rowdata_packet
converted = converter(self.connection, field, data)
File "/home/mk/.local/lib/python3.2/site-packages/pymysql/
converters.py", line 337, in convert_decimal
return Decimal(data)
File "/usr/lib/python3.2/decimal.py", line 660, in __new__
raise TypeError("Cannot convert %r to Decimal" % value)
TypeError: Cannot convert b'1.0' to Decimal
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/mk/arbeit/mytest.py", line 12, in <module>
dbCursor.execute (query)
File "/home/mk/.local/lib/python3.2/site-packages/pymysql/
cursors.py", line 108, in execute
self.errorhandler(self, exc, value)
File "/home/mk/.local/lib/python3.2/site-packages/pymysql/
connections.py", line 182, in defaulterrorhandler
raise Error(errorclass, errorvalue)
pymysql.err.Error: (<class 'TypeError'>, TypeError("Cannot convert
b'1.0' to Decimal",))