[DB-SIG] locale mysql and wxpython

William Dode wilk@flibuste.net
Mon, 6 May 2002 11:22:37 +0200


I'm french, so my locale is set to fr_FR.
When I use mysql AND wxpython, a query with a float throw an exception of
invalid literal for float()

import locale
from wxPython.wx import wxPySimpleApp # if I remove this line it will work
ort=3306) cursor=db.cursor()
cursor.execute("select livre.prix from livre") # livre.prix is a float
print res

 File "/usr/lib/python2.1/site-packages/MySQLdb/cursors.py", line 136, in
_fetch_row    return self._result.fetch_row(size, self._fetch_type)
ValueError: invalid literal for float(): 68.00

People from wxPython said that wxpython do an
locale.setlocale(locale.LC_ALL,''), but if I do it without importing
wxpython it does'nt throw an exception...

If I do os.putenv("LC_ALL","C") it will work...

any idea from where comes the problem ?

thanks to read my poor english writing

William Dodé - Informaticien Indépendant