Hi everyone, I'm trying to manage read and write operations of utf-8 unicode strings with SQL Server (sqlalchemy 0.9.10), but I'm having some problems. I correctly write the strings to the database, but when I read them back and try to convert to unicode I get the following error:
Traceback (most recent call last): File "C:\Users\Impara 01\Desktop\t.py", line 18, in <module> print unicode(row[0], "utf-8") UnicodeDecodeError: 'utf8' codec can't decode byte 0xe0 in position 0: invalid continuation byte Process terminated with an exit code of 1 Here is a sample code showing the problem: # -*- coding: utf-8 -*- import sqlalchemy from sqlalchemy import select, create_engine, MetaData, Table, Column import datetime engine = create_engine('mssql+pyodbc://MYHOST\SQLEXPRESS/user?trusted_connection=True&charset=utf8') metadata = MetaData(engine) t = Table('test', metadata, Column('unicode', sqlalchemy.dialects.mssql.VARCHAR()) ) t.create() s = "àèìòù" s = unicode(s, "utf-8") t.insert().values(unicode=s).execute() res = select([t.c.unicode]).execute().fetchall() for i, row in enumerate(res): print unicode(row[0], "utf-8") Can anyone point me out what I'm doing wrong? Thanks in advance! -- 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. For more options, visit https://groups.google.com/d/optout.