python - Pymssql, How to use it to read unicode data from MSSQL2008 -
i've used pymssql-1.0.2 , freetds-0.82.7 on ubuntu-10.10. also, have mssql2008 server on windows-7. can connect mssql ubuntu using pymssql , freetds. can't unicode data mssql database. database collation cyrillic_general_ci_as.
my freetds.conf file looks this:
[mssql2008] host=10.0.0.34 port=1433 tds version=7.0
my code looks this:
conn = pymssql.connect(host=10.0.0.34\mssql2008, user=***, password=***, database=eoffice, as_dict=true, charset='iso-8859-1') crms = conn.cursor() crms.execute('select cc_name tblhr_codeclass') row in crms.fetchall(): raise u"succeeded! test data: " + row['cc_name'] break
expected result is: "Өмнөговь аймаг" actual result is: "ªìíºãîâü àéìàã"
when use 'utf-8' charset, fetchall() call throws error means utf8 can't read data out of range of code page.
how unicode data stored on mssql database? please give hand!
regards, orgil
is unicode data? i.e., cc_name column varchar or nvarchar? sounds it's varchar--in case, try using cp1251 or windows-1251 charset instead of iso-8859-1.
Comments
Post a Comment