well, i came up with a solution, which is a rather crappy hack though: changing 2 lines in db.py line 123: else: self.items = [items] ##NEW # self.items = [str(items)] ##OLD
line 555: if self.printing: try: print >> debug, '%s (%s): %s' % (round(b-a, 2), self.ctx.dbq_count, udec(sql_query)) ##NEW except: print 'unicode error' # print >> debug, '%s (%s): %s' % (round(b-a, 2), self.ctx.dbq_count, str(sql_query)) ##OLD aint there a better way to do it?? On Aug 9, 1:47 pm, max <max.fech...@gmail.com> wrote: > Hi, > i have a problem with web.db regarding german characters. > i want to issue the following statement: > > UPDATE way SET name='Raststätte Breisgau', highway='service' > WHERE id='4018427' > > when i interact with the (mysql-)database via 'sqlbuddy', everything > works just fine. > > submitting the statement via web.db however, results in the following > error. > > UPDATE way SET name='Raststätte Breisgau', highway='service' WHERE > id='4018427' > Traceback (most recent call last): > File "./extractStreets.py", line 38, in <module> > dbx.query('way').update(id=way.id).values > (name=name,highway=typ).result() > File "/home/max/web/lib/py/dbx0.py", line 163, in result > def result(self): return self._db.query(self.sql()) > File "/usr/lib/python2.5/site-packages/web.py-0.32-py2.5.egg/web/ > db.py", line 587, in query > sql_query = reparam(sql_query, vars) > File "/usr/lib/python2.5/site-packages/web.py-0.32-py2.5.egg/web/ > db.py", line 263, in reparam > return SQLQuery.join(result, '') > File "/usr/lib/python2.5/site-packages/web.py-0.32-py2.5.egg/web/ > db.py", line 196, in join > q = SQLQuery(items[0]) > File "/usr/lib/python2.5/site-packages/web.py-0.32-py2.5.egg/web/ > db.py", line 124, in __init__ > self.items = [str(items)] > UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in > position 27: ordinal not in range(128) > > i tried to execute the following commands upfront. that didnt help: > > db.query('SET NAMES utf8;') > db.query('SET CHARACTER SET utf8;') > db.query('SET character_set_connection=utf8;') > > i could skip the error by converting to unicode, then back to str. > this leaves the generated database entry crippled though. like > 'Rastst' instead of 'Raststätte Breisgau' > (the dbx line in the error-message [dbx.query('way').update > (id=way.id).values(name=name,highway=typ).result()] is just my own sql- > generator, the resulting sql ist passed to web.db.query() then) > > thanks so much for your help! > > Max Fechner --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web.py" group. To post to this group, send email to webpy@googlegroups.com To unsubscribe from this group, send email to webpy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/webpy?hl=en -~----------~----~----~----~------~----~------~--~---