-1

I connection to Mssql server on python 2.7 by pymssql. Connection string is:

mssql+pymssql://user:pass@server:1433/DB

And Collation of server is Cyrillic_General_CI_AS. When i try select from table with column of varchat it return string:

u'ÎÎÎ "ÒÎÐÏÅÄÀ"'

I did try to convert it with:

"ÎÎÎ "ÒÎÐÏÅÄÀ".decode('866')

And get output:

├О├О├О "├Т├О├Р├П├Е├Д├А"

But correct String in database is:

ООО "ТОРПЕДА"

It seems like each second simbol is correct. How to get all varchar2 strings at correct encoding? Thank you

Ivan Bryzzhin
  • 2,009
  • 21
  • 27
  • what about your display environment? you have to use the SAME charset everywhere, or have appropriate translation logic at the borders. – Marc B Sep 11 '15 at 15:46
  • I try show it by Flask at html page. Select return me incorrect unicode string as i show at first string example. I found example as i can change encoding at connection string: mssql+pymssql://user:pass@server:1433/DB:charset=utf8. But it return the same incorrect unicode. – Ivan Bryzzhin Sep 11 '15 at 16:00

1 Answers1

0

Just found the answer after i did post the question:

u'ÎÎÎ "ÒÎÐÏÅÄÀ"'.encode('latin1').decode('1251')

May be there is a better solution, but after few days of looking i did't found.

Ivan Bryzzhin
  • 2,009
  • 21
  • 27