Using MySQLdb I connect to a database where everything is stored in the utf8 encoding.
If I do
cursor.execute("SET NAMES utf8")
and fetch some data from the database by another statement. Does that mean, that the strings in
cursor.execute("SELECT ...")
cursor.fetchall()
will be in unicode? Or do I have to turn them first by
mystr.decode("utf8")
to unicode?
From the docs:
connect(parameters...)
...
use_unicode
If True, CHAR and VARCHAR and TEXT columns are returned as Unicode strings, using the configured character set. It is best to set the default encoding in the server configuration, or client configuration (read with read_default_file). If you change the character set after connecting (MySQL-4.1 and later), you'll need to put the correct character set name in connection.charset.
If False, text-like columns are returned as normal strings, but you can always write Unicode strings.
This must be a keyword parameter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With