I'm having problem when adding some unicode text into database:
import web
db = web.database(dbn='sqlite', db=':memory:')
db.query('create table test(t text)')
db.insert('test', t='€')
db.insert('test', t='€'.decode('utf8'))
then I get this:
---------------------------------------------------------------------------
ProgrammingError Traceback (most recent call
last)
/usr/home/sec/<ipython console> in <module>()
/usr/local/lib/python2.6/site-packages/web/db.pyc in insert(self,
tablename, seqname, _test, **values)
699 # the id of the inserted row.
700 q1, q2 = sql_query
--> 701 self._db_execute(db_cursor, q1)
702 self._db_execute(db_cursor, q2)
703 else:
/usr/local/lib/python2.6/site-packages/web/db.pyc in _db_execute(self,
cur, sql_query)
528 out = cur.execute(sql_query.query(paramstyle),
529 [self._py2sql(x)
--> 530 for x in sql_query.values()])
531 b = time.time()
532 except:
ProgrammingError: You must not use 8-bit bytestrings unless you use a
text_factory that can interpret 8-bit bytestrings (like text_factory =
str). It is highly recommended that you instead just switch your
application to Unicode strings.
Using web.py 0.3, python 2.6.2. What I'm doing wrong? When I switch
text_factory to str (it's unicode by default) it's working but I don't
think it's good way to handle this.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---