sql server - python to mssql encoding problem -


greetings

by using pymssql library, want write data mssql database encounter encoding issues. here sample code write db:

# -*- coding: utf-8 -*- import _mssql  .... connection info data here ....   def mssql_connect():     return _mssql.connect(server=host, user=username, password=pass, database=db, charset="utf-8")  con = mssql_connect() insert_ex_sql = "insert mydatabsae (id, programname, programdetail) values (1, 'test characters ÜŞiçÇÖö', 'löşüiiğĞü');" con.execute_non_query(insert_ex_sql) con.close() 

sadly data written db corrupted:

enter image description here

the collacation of mssql db is: turkish_ci_as how can solved?

here possible solution:

the key insert_ex_sq.encode('your language encoder'). try instead:

con.execute_non_query(insert_ex_sq.encode('your language encoder')) 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -