[DB-SIG] locale mysql and wxpython

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


Hi,

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
db=MySQLdb.connect(db="flibuste",user="wilk",passwd="xxx",host="blakie",p
ort=3306) cursor=db.cursor()
cursor.execute("select livre.prix from livre") # livre.prix is a float
res=cursor.fetchall()
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
http://www.flibuste.net