Open GoogleCodeExporter opened 9 years ago
[deleted comment]
Found the way:
/etc/freetds/freetds.conf
[MS_Server]
host = localhost
port = 1433
tds version = 8.0
client charset = SHIFT-JIS
/etc/odbcinst.ini
[ODBC]
Trace = No
TraceFile = /tmp/odbc.log
[FreeTDS]
Description = TDS driver (Sybase/MS SQL)
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
/etc/odbc.ini
[ODBC Data Sources]
ODBCNAME = Microsoft SQL Server
[MS_SQL_CONNECTION]
Description = ODBC connection via FreeTDS
Driver = FreeTDS
Servername = MS_Server
Database = db_name
[Default]
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
---------------
#!/usr/bin/python
import pyodbc
user = ''
password = ''
dsn = 'MS_SQL_CONNECTION'
con_string = r'DSN=%s;UID=%s;PWD=%s;' % (dsn, user, password)
cnxn = pyodbc.connect(con_string)
cursor = cnxn.cursor()
cursor.execute("""SELECT TOP 1 field FROM T_table""")
row = cursor.fetchone()
print row[0]
print row[0].decode('sjis')
Original comment by tsuneo.o...@gmail.com
on 4 Jun 2013 at 1:51
Original issue reported on code.google.com by
tsuneo.o...@gmail.com
on 30 May 2013 at 3:59