convert_unicode these days is by default "conditional" - if the DBAPI accepts
Python unicode objects directly, and/or can be coerced to return unicode
objects directly, SQLAlchemy doesn't do any encoding. This is the case with
psycopg2 which both accepts Python unicode objects as bound parameters and via
its "unicode" extension returns them also. It does not matter what kind of
data was passed to the database, provided the data got in with the configured
encoding, it's in, you always get a "unicode" value back.
If you're writing a "unicode compatible" application, you'd never pass a
"bytestring" to such a column that is, not:
"somestring"
instead, always pass a unicode object:
u"somestring"
SQLAlchemy doesn't do anything with the former, nor does psycopg2 - the data
contained within is essentially unknown.
On Oct 28, 2011, at 7:36 AM, Manav Goel wrote:
> Hi
> I am using sqlalchemy with postgresql and psycopg2. I want to write
> unicode compatible web application.
> I noticed that when I pass string data to sqlalchemy string column, its get
> converted to unicode after commit.
>
> So does setting convert_unicode option True has any meaning in this
> combination of postgre and psycopg2?
>
> If it converts str to unicode in any case would it be useful to use only
> unicode from start? I mean assign u prefix before passing normal english
> string.
>
> Regards,
> Manav Goel
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> To unsubscribe from this group, send email to
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/sqlalchemy?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.