469,581 Members | 1,960 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,581 developers. It's quick & easy.

MySQLdb and Unicode

Hi,

I try to write unicode strings to a MySQL database via MySQLdb.
According to the documentation I should pass 'utf-8' as keyword
parameter to the connect method. But then I get the following error:
Traceback (most recent call last):
File "C:\develop\SyynX\unicode_test.py", line 7, in ?
con=MySQLdb.connect(host='localhost',db='unicode_t est',unicode='utf-8')
File "C:\Python24\Lib\site-packages\MySQLdb\__init__.py", line 66, in
Connect
return Connection(*args, **kwargs)
File "C:\Python24\Lib\site-packages\MySQLdb\connections.py", line
134, in __init__
super(Connection, self).__init__(*args, **kwargs2)
TypeError: 'unicode' is an invalid keyword argument for this function
I'm using version 1.2 of MySQLdb. Any hint what I'm doing wrong?

regards,
Achim
Jul 19 '05 #1
1 2889
Achim Domma (Procoders) wrote:
Hi,

I try to write unicode strings to a MySQL database via MySQLdb.
According to the documentation I should pass 'utf-8' as keyword
parameter to the connect method. But then I get the following error:
(...)

I'm using version 1.2 of MySQLdb. Any hint what I'm doing wrong?


this is changed in 1.2, from the Connection class docstring:

"use_unicode"

''If True, text-like columns are returned as unicode objects
using the connection's character set. Otherwise, text-like
columns are returned as strings. columns are returned as
normal strings. Unicode objects will always be encoded to
the connection's character set regardless of this setting.''

--
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<#me> a foaf:Person ; foaf:nick "deelan" ;
foaf:weblog <http://blog.deelan.com/> .
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Dave Harrison | last post: by
1 post views Thread by Peter Nikolaidis | last post: by
3 posts views Thread by Achim Domma | last post: by
1 post views Thread by Steve | last post: by
1 post views Thread by Yi Xing | last post: by
5 posts views Thread by Harold Trammel | last post: by
3 posts views Thread by Robin Becker | last post: by
2 posts views Thread by Nikhil | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.