Thanks Mike.
I know I must use unicode, and, in a matter of fact, I do respect the
first item of your list. That's why I asked here :)
I'll try items 2 and 5 (which seems more appropriate, since my
application runs only on Postgres).
Best regards,
Richard.
On 05/06/2013 05:50 PM, Michael Bayer wrote:
this happens when you do this:
class SomeClass(Base):
# ...
some_col = Column(Unicode(50))
s = SomeClass(somestring='some value')
and then when you commit "s" to the database, the bytestring is
detected and the warning emitted. Note 'some value' is a Python
bytestring, not a Unicode string, that is: u'some value'.
Solutions:
1. use unicode strings, u'some value'.
2. turn on u'' everywhere, using "from __future__ import unicode_literals"
3. use a "coercing" unicode type, see the example at
http://docs.sqlalchemy.org/en/rel_0_8/core/types.html#coercing-encoded-strings-to-unicode
4. turn the warning off: http://docs.python.org/2/library/warnings.html
5. use the Unicode type with convert_unicode=False: Column(Unicode(50,
convert_unicode=False)) - since you're using psycopg2, SQLAlchemy
doesn't need to be involved here and setting this flag will disable
the check.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.