Python unicode utf-8 characters and MySQL unicode utf-8 characters

Discussion in 'Python' started by Grzegorz ¦liwiñski, Jan 18, 2011.

  1. Hello,
    Recently I tried to insert some unicode object in utf-8 encoding into
    MySQL using MySQLdb, and got MySQL warnings on characters like:
    ðŽ²ðŽ ðŽ¥ðŽ  i found somewhere in my data. I can't even read them. MySQL
    seems to cut the whole string after that characters off, so I get
    incomplete data.
    After a little bit of digging I found out, that MySQL usually supports
    utf-8 data but encoded into maximum three bytes. That's why I think it
    would help I f I was able to replace all larger unicode characters
    with replacement characters.

    Is there any way, I could adjust python unicode utf-8 encoded strings
    to be accepted by mysql utf-8 columns?
    Grzegorz ¦liwiñski, Jan 18, 2011
    #1
    1. Advertising

  2. 2011/1/18 Grzegorz Śliwiński <>:
    > Hello,
    > Recently I tried to insert some unicode object in utf-8 encoding into
    > MySQL using MySQLdb, and got MySQL warnings on characters like:
    > ðŽ²ðŽ ðŽ¥ðŽ  i found somewhere in my data. I can't even read them. MySQL
    > seems to cut the whole string after that characters off, so I get
    > incomplete data.
    > After a little bit of digging I found out, that MySQL usually supports
    > utf-8 data but encoded into maximum three bytes. That's why I think it
    > would help I f I was able to replace all larger unicode characters
    > with replacement characters.
    >
    > Is there any way, I could adjust python unicode utf-8 encoded strings
    > to be accepted by mysql utf-8 columns?


    Did you pass the charset argument when creating your MySQLdb connection?

    --
    regards,
    kushal
    Kushal Kumaran, Jan 18, 2011
    #2
    1. Advertising

  3. On 18 Sty, 18:15, Kushal Kumaran <>
    wrote:
    > 2011/1/18 Grzegorz Śliwiński <>:
    >
    > > Hello,
    > > Recently I tried to insert some unicode object in utf-8 encoding into
    > > MySQL using MySQLdb, and got MySQL warnings on characters like:
    > > ðŽ²ðŽ ðŽ¥ðŽ  i found somewhere in my data. I can't even read them. MySQL
    > > seems to cut the whole string after that characters off, so I get
    > > incomplete data.
    > > After a little bit of digging I found out, that MySQL usually supports
    > > utf-8 data but encoded into maximum three bytes. That's why I think it
    > > would help I f I was able to replace all larger unicode characters
    > > with replacement characters.

    >
    > > Is there any way, I could adjust python unicode utf-8 encoded strings
    > > to be accepted by mysql utf-8 columns?

    >
    > Did you pass the charset argument when creating your MySQLdb connection?
    >
    > --
    > regards,
    > kushal


    Hello, yes, although I usually just use SET NAMES utf8; after
    encountering the problem first, I tried the charset option as well,
    but there's no difference.
    Grzegorz ¦liwiñski, Jan 19, 2011
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ray well
    Replies:
    9
    Views:
    14,044
  2. Robert Mark Bram
    Replies:
    0
    Views:
    3,917
    Robert Mark Bram
    Sep 28, 2003
  3. ronrsr
    Replies:
    1
    Views:
    908
    Carsten Haese
    Jan 2, 2007
  4. Hans Müller
    Replies:
    1
    Views:
    287
    Hans Müller
    Dec 3, 2009
  5. majna
    Replies:
    4
    Views:
    656
    Thomas 'PointedEars' Lahn
    Sep 19, 2007
Loading...

Share This Page