But i can't find way to insert "utf-8" data into MysSQL database!
For example:

tusers = db.define_table( 'users',
     Field( 'login', 'string',
            required = True,
            notnull  = True,
            unique   = True ),
     Field( 'passw', 'string',
            required = True,
            notnull  = True ),
     Field( 'email', 'string',
            length   = 100,
            required = True,
            notnull  = True,
            unique   = True ),
     Field( 'state', 'string',
            length   = 100 ))

But nothing of this is work :
1)  tusers.insert( login = "Русский", email = "English",  passw =
"English", state = "English" )
2)  tusers.insert( login = u"Русский", email = "English",  passw =
"English", state = "English" )

1) and 2) does not work, because it produce exception of this type:
--------------------------------
[exception]-------------------------------
  File "/usr/lib/python2.4/site-packages/MySQLdb/cursors.py", line
146, in execute
    query = query.encode(charset)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
55: ordinal not in range(128)
-------------------------------------------------------------------------------

"query" is a simple python non unicode string.

I.e. type( query ) == <type 'str'>
But only type( query ) == <type 'unicode'> can be encoded with non
ASCII chars.

Try this:
>>> s = "фыва"
>>> s.encode( 'utf8' )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd1 in position
0: ordinal not in range(128)

What the best way to insert unicode data from request.vars to
database ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to