Menu

character_set errors about MySQLdb

Help
2008-11-20
2012-09-19
  • liang naichen

    liang naichen - 2008-11-20

    hello everyone:

    >>> conn = MySQLdb.connection(host ="",user = "root", passwd = "123456", db = "django_test");
    >>>
    >>> charset = conn.character_set_name()
    >>> charset
    'latin1_swedish_ci'


    the character set of mysql is latin1,'latin1_swedish_ci' is the correspoding collation;however conn.character_set_name() returns 'latin1_swedish_ci',it is obviously wrong.
    LookupError: unknown encoding: latin1_swedish_ci
    oh my god.
    when I use django's session, I need to first create several tables,so I input the following command:
    ./manage.py syncdb
    then error took place
    "LookupError: unknown encoding: latin1_swedish_ci"
    and I traced back it and found that the content of 146-149 rows in the file cursors.py are:
    db = self._get_db()
    charset = db.character_set_name()
    if isinstance(query, unicode):
    query = query.encode(charset)
    because charset is 'latin1_swedish_ci',
    query = query.encode('latin1_swedish_ci')
    then
    !!!"LookupError: unknown encoding: latin1_swedish_ci"!!!

    can anyone give some suggestions?
    thank you in advance!

     
    • liang naichen

      liang naichen - 2008-11-20

      mysql :4.1.7
      MySQLdb:1.2.2
      python:2.5.2
      django:1.0

      as far as I know, they are compatible.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.