On Apr 13, 6:26 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> Do you mean that you are coming across a case of trying to store 4-byte
> UTF-8 sequences in MySQL? Or do you mean that you've managed to create a
> database table with the incorrect encoding and only realised this after
> you've stored data in the table? Or is there a third possibility?

Thanks for the follow up...

In my particular case I have an old database with content that has
built up over the years from a PHP website.  I'm re-building the site
in Django and am working on a database migration script.  For various
text fields in the old tables I was hitting this same error,
"Incorrect string value: '\x[something or other]'  for column
'[something]' at row 1".

I actually ended solving it by telling MySQLdb to "use_unicode", e.g.:
db = MySQLdb.connect(host=OLD_DB_HOST, user=OLD_DB_USER,
passwd=OLD_DB_PASS, db=OLD_DB_NAME, use_unicode=True)

I believe the old tables were latin-1 encoded so it seems like this
forces them to be unicode encoded which made pushing into the new
tables as utf8 work correctly?

Thanks,
Rob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to