Skip to content

Commit fa6ea28

Browse files
committed
use better format for float
1 parent 3674bc6 commit fa6ea28

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pymysql/converters.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ def escape_int(value, mapping=None):
5454
return str(value)
5555

5656
def escape_float(value, mapping=None):
57-
return ('%.15g' % value)
57+
s = repr(value)
58+
if s in ('inf', 'nan'):
59+
raise ProgrammingError("%s can not be used with MySQL" % s)
60+
if 'e' not in s:
61+
s += 'e0'
62+
return s
5863

5964
_escape_table = [unichr(x) for x in range(128)]
6065
_escape_table[0] = u'\\0'

0 commit comments

Comments
 (0)