Sunday, 15 July 2012

sql server - Connect to MS SQL database using freetds, unixodbc and python -



sql server - Connect to MS SQL database using freetds, unixodbc and python -

i'm running ubuntu 12.04 on 32-bit computer, , want connect ms sql database using freetds, unixodbc , python, i'm getting error:

>>> import pyodbc >>> conn = pyodbc.connect('dsn=ts;uid=myusername;pwd=mypassword') traceback (most recent phone call last): file "<stdin>", line 1, in <module> pyodbc.error: ('im002', '[im002] [unixodbc][driver manager]data source name not found, , no default driver specified (0) (sqldriverconnect)')

this /etc/freetds.conf file:

[ts] host = 192.168.254.50 port = 1433 tds version = 7.0 client charset = utf-8

this /etc/odbc.ini file:

--- /etc/odbc.ini --- [ts] description = "test" driver = freetds server = 192.168.254.50 port = 1433 database = db_name

this /etc/odbcinst.ini file:

--- /etc/odbcinst.ini --- [freetds] description = freetds driver = /usr/lib/i386-linux-gnu/odbc/libtdsodbc.so

when seek test out on bash using tsql, works:

$ tsql -s ts -u myusername -p mypassword locale "en_sg.utf-8" locale charset "utf-8" using default charset "utf-8" 1> utilize db_name 2> go 1> select top 10 label db_name.tablename 2> go [... info here ...] (10 rows affected) 1>

however, testing using isql doesn't, , gives similar error in python prompt:

$ isql -v ts myusernam mypassword [im002][unixodbc][driver manager]data source name not found, , no default driver specified [isql]error: not sqlconnect

can help me out please?

python sql-server ubuntu-12.04 freetds unixodbc

No comments:

Post a Comment