[DB-SIG] Unicode interaction with the python DBAPI?
farcepest at gmail.com
Mon Jul 26 21:19:09 CEST 2004
On Mon, 26 Jul 2004 10:28:12 -0400, Mihai Ibanescu <misa at redhat.com> wrote:
> What is the driver supposed to do when it receives Unicode data?
MySQLdb does it this way: If you pass unicode=True to connect(), then
any string data is returned as Unicode strings; otherwise it uses
normal strings. In MySQL < 4.1, the character set is server
configuration variable, and won't change during the course of
execution. In MySQL >= 4.0 (I think 4.1 is included in this), you can
set character sets on columns (or maybe just tables); so far, >= 4.1
is not supported by MySQLdb.
Even if you don't set unicode=True, it will encode any unicode strings
passed as parameters into normal strings (needed to insert into the
query statement; parameter substitution is in 4.1).
More information about the DB-SIG