The wirdest thing is that if I write:

ob = Test2('just a test')
session.save(ob)
session.commit()

2009-06-18 17:08:15,251 INFO sqlalchemy.engine.base.Engine.0x..74 INSERT
INTO test2 (comment) VALUES (?)
2009-06-18 17:08:15,251 INFO sqlalchemy.engine.base.Engine.0x..74 ['just a
test']
2009-06-18 17:08:15,262 INFO sqlalchemy.engine.base.Engine.0x..74 COMMIT

Everything works fine, but if I write:

ob = Test2(u'товарни автомобили')
session.save(ob)
session.commit()

Output is:
[cor...@localhost bin]$ ./python test2.py
2009-06-18 16:55:22,754 INFO sqlalchemy.engine.base.Engine.0x..94 BEGIN
2009-06-18 16:55:22,755 INFO sqlalchemy.engine.base.Engine.0x..94 INSERT
INTO test2 (comment) VALUES (?)
2009-06-18 16:55:22,755 INFO sqlalchemy.engine.base.Engine.0x..94
['\xd1\x82\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x80\xd0\xbd\xd0\xb8
\xd0\xb0\xd0\xb2\xd1\x82\xd0\xbe\xd0\xbc\xd0\xbe\xd0\xb1\xd0\xb8\xd0\xbb\xd0\xb8']
2009-06-18 16:55:22,787 INFO sqlalchemy.engine.base.Engine.0x..94 COMMIT

And in the database, column is empty! no data, just blank.


On Thu, Jun 18, 2009 at 6:43 PM, phrrn...@googlemail.com <
phrrn...@googlemail.com> wrote:

>
> You should put this into your .freetds.conf file to ensure that
> FreeTDS will tell iconv to do the right thing (my understanding is
> that all unicode data is encoded to UCS-2 by FreeTDS)
>
>   tds version = 8.0
>   client charset = UTF-8
>
> SQL Alchemy create_engine has an encoding kwarg:
> encoding='utf-8' - the encoding to use for all Unicode translations,
> both by engine-wide unicode conversion as well as the Unicode type
> object
>
> This should be set to the same value as you have for 'client charset'
> in the .freetds.conf file.
>
> You can run into problems when bogus data has been stuff into the
> nvarchar field at the dataserver as it will cause the python codec to
> blow up when retrieving the data so "Don't Do That" (I discovered this
> the hard way by having a server-side job that was populating the data
> and not ensuring that the encoding was well-formed)
>
>
> pjjH
>
>
>
> >
>


-- 
The brain is a wonderful organ. It starts working
the moment you get up in the morning, and
does not stop until you get into the office.
Robert Frost (1874-1963)

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to