#185 UTF8 inconvenience: getting array objects instead of strings

MySQLdb-1.2
closed
Andy Dustman
MySQLdb (285)
5
2012-09-19
2006-05-26
Bart Alewijnse
No

I switched collations on some columns from
utf8_general_ci to utf8_bin, because the former was
interfering with UNIQUE constraints.

The problem is that MySQL or its library (for some
reason I can't fathom) treats this particular
charset/collation combination as a BLOB, which means
MySQLdb does not give me a unicode/utf string but
rather binary data, or actually binary data wrapped
inside an array.array('c', 'string') object, which
ruins the generality of the interface and makes it
rather more bothersome to use the database in a 'utf8
in, utf8 out' way.

I would prefer this particular collation to work as the
former (and I assume any other) utf8
collation/encoding. I am now sure where this bug
originates, though - it is possible this should MySQL
itself.

(MySQLdb 1.2.0-r1, MySQL 5.0.19, Python 2.4.2, gentoo, x86)

Discussion

  • Andy Dustman
    Andy Dustman
    2006-05-26

    Logged In: YES
    user_id=71372

    Internally to MySQL, the only difference between BLOB and
    TEXT columns is whether or not they have a binary collation.
    They have the same numeric column type, but BLOBs and TEXT
    columns with a binary collation have a BINARY flag set.

     
  • Andy Dustman
    Andy Dustman
    2006-08-26

    Logged In: YES
    user_id=71372

    Fixed in development version; please test 1.2.2b2 when it is
    release (mysql-python-test).