Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3748177

Browse files
author
adustman
committed
https://sourceforge.net/tracker/?func=detail&aid=850174&group_id=22307&atid=374932
Use more precision for floats; str(<float>) doesn't return full precision.
1 parent d0b77ee commit 3748177

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

MySQLdb/MySQLdb/converters.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ def Long2Int(l, d):
5454
else:
5555
Long2Int = Thing2Str
5656

57+
def Float2Str(o, d):
58+
return '%.15g' % o
59+
5760
def None2NULL(o, d):
5861
"""Convert None to NULL."""
5962
return NULL # duh
@@ -105,7 +108,7 @@ def array2Str(o, d):
105108
conversions = {
106109
types.IntType: Thing2Str,
107110
types.LongType: Long2Int,
108-
types.FloatType: Thing2Str,
111+
types.FloatType: Float2Str,
109112
types.NoneType: None2NULL,
110113
types.TupleType: escape_sequence,
111114
types.ListType: escape_sequence,

0 commit comments

Comments
 (0)