Sounds good. Thanks Jason!

On 8/20/07, jason kirtland <[EMAIL PROTECTED]> wrote:
>
>
> Arun wrote:
> > So in short if I specify use_unicode=True at the SA engine level
> > then I can skip specifying use_unicode and specify only
> > charset=utf8 at mysqldb level ?
>
> If you configure this DB-API driver for all-Unicode (which is what
> happens when you only give it a 'charset') all strings will come
> back from the database to SQLAlchemy as Unicode.  You can ask the
> Engine and/or types to convert_unicode=True, but it won't do
> anything except add processing overhead- the strings are already
> Unicode from the driver.
>
> Try playing with the following to find a combination that suits
> your needs.  The first two engine configurations aren't options for
> you obviously, but they make a good demo.
>
> from sqlalchemy import *
> e = create_engine('mysql:///test')
> #e = create_engine('mysql:///test', convert_unicode=True)
> #e = create_engine('mysql:///test?charset=utf8')
> #e = create_engine('mysql:///test?charset=utf8',
> #                  convert_unicode=True)
> #e = create_engine('mysql:///test?charset=utf8&use_unicode=0')
> #e = create_engine('mysql:///test?charset=utf8&use_unicode=0',
> #                  convert_unicode=True)
>
> m = MetaData(e)
> t = Table('unicodings', m,
>           Column('string', String(32)),
>           Column('unicode', Unicode(32)))
>
> if not t.exists():
>     t.create()
>     t.insert().execute({'string':'foo',
>                         'unicode':'bar'})
>
> print repr(list(t.select().execute()))
>
>
> >
>


-- 
Cheers,

- A

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

Reply via email to