Max, I have no problems by only using Unicode field-types in my model; that
is, my sqlalchemy connection string does not contain anything related to
UTF-8. I haven't investigated my MySQL setup so thoroughly but it seems to
work with MySQL 4 and 5 and stable and development versions of mysqldb. It
is quite possible that the data being stored in the database is in
iso-8859-1 or whatever MySQL uses by default but SQLAlchemy is
automatically manipulating the binary stirngs into Unicode objects based on
the encoding of the database.

Ideally, I'd like to see a best practice of, basically, stop worrying
specifically about MySQL database encoding and all of its nastiness and
simply use Unicode fields instead of String fields for data that holds
natural language characters.

Can anyone else confirm that this works as I describe?

Cheers,
David

Max Ischenko wrote:

> On 5/11/07, andyprog
> <[EMAIL PROTECTED]> wrote:
>>
>>
>> Hi all,
>>
>> (I'm using Pylons for the first time, so pls bear with me...)
>>
>> I'm setting up a Pylons app with Mako + SQLAlchemy + MySQL + UTF-8
>> support
>> -- but I've had trouble finding one place with clear instructions on
>> how to do this,
>> so I've gathered pieces of info from here and there, but this, coupled
>> with the fact
>> that some instructions are outdated, and others not so clear, has left
>> me quite confused... :(
> 
> 
> It is outdated indeed.
> 
> If you have the latest stable version of Pylons, SA and MySQLdb (1.2.2)
> the following should be enough:
> 
> sqlalchemy.dburi = mysql://...?charset=utf8
> 
> And you should get properly decoded unicode strings from SA.
> 
> Btw, make sure your mysql db really contains utf8-encoded data (use mysql
> console in utf8 locale to poke around and "show full columns" to check
> collation.
> 
> Max.
> 
> 


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

Reply via email to