FREETDS and UNIXODBC character converting
Asked Answered
A

2

10

ive got an error to fix. its:

[FreeTDS][SQL Server]Error converting characters into server's character set. Some character(s) could not be converted

when i use turkish characters to insert i get this error. my question is how can i disable that converting thing? im connecting to sql server via freetds and unixodbc.

thanks..

Adjuvant answered 27/5, 2010 at 16:15 Comment(0)
B
9

You need to set

clientcharset = UTF-8

in your freetds.conf file and read it from odbc.ini by setting the Servername option to the connection definition in freetds.com. See this explanation and my blog post.

Biotope answered 28/11, 2010 at 18:20 Comment(2)
Thankyou! It has taken me many hours to resolve a similar issue. Who would have known that the client charset in the global section of freetds.conf was ignored.Impedimenta
Please note, that proper setting for TDS 8.0 is "clientcharset = UTF-8" - without whitespace. If I have known that, I would safe hours of searching...Lunch
D
2

in python3, you need to add two lines after your conn

import pyodbc as db # forgot the imports
conn = pyodbc.connect(driver=driver, server=serv, database=db,port = prt,
                  uid=usr, pwd=passwd)
conn.setdecoding(db.SQL_CHAR, encoding='latin1')
conn.setencoding('latin1')
Devious answered 10/8, 2021 at 15:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.