标签:des style blog http color 使用
tar zfvx freetds-stable.tgz cd freetds-* ./configure --prefix=/usr/local/freetds --with-tdsver=7.1 --enable-msdblib make sudo make install(注意是root)
apt-get freetds-bin
tsql –H mssql-server-ip –U username –P password
apt-get install unixodbc unixodbc-dev unixodbc-bin tdsodbc
[TDS] Description = FreeTDS Driver for Linux & MSSQL on Win32 Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
[TDS]这一行意为开始定义一个名叫TDS的数据库驱动,下面是这个数据库的相关属性,请检查一下,Driver和Setup所指的两个lib文件是否存在或路径是否正确,如果不存在,要好好检查一下这一步的安装工作有没到位啦,现在把tds.driver.template里定义的数据库驱动安装到系统的ODBC驱动库,执行如下命令:
sudo odbcinst -i -d -f tds.driver.template
[my_data] Description = Connection to windows virtual machine Driver = TDS Trace = No Database = p10 Server = 192.168.88.200 Port = 1433 TDS_Version = 7.1
sudo odbcinst -i -s -l -f tds.datasource.template
sudo isql my_data sa password +---------------------------------------+ | Connected! | | | | sql-statement | | help [tablename] | | quit | | | +---------------------------------------+ SQL>
sudo pip install pyodbc
python >>import pyodbc >> conn=pyodbc.connect(‘DSN=数据源名;UID=用户名;PWD=密码‘)
conn=pyodbc.connect(‘DSN=数据源名;DATABASE=数据库名;UID=用户名;PWD=密码‘)
tsql –H 192.168.88.146 –U sa –P dingjia -p 1433 locale is "zh_CN.UTF-8" locale charset is "UTF-8" using default charset "UTF-8" 1>
sudo isql my_data sa password +---------------------------------------+ | Connected! | | | | sql-statement | | help [tablename] | | quit | | | +---------------------------------------+ SQL>
python >>import pyodbc >> conn=pyodbc.connect(‘DSN=数据源名;UID=用户名;PWD=密码‘)
如果想指定连接哪个数据库的话,可以修改配置文件odbc.ini,把Database的值留空,使用时即可指定数据库。
Ubuntu12.10下Python(pyodbc)访问SQL Server解决方案,布布扣,bubuko.com
Ubuntu12.10下Python(pyodbc)访问SQL Server解决方案
标签:des style blog http color 使用
原文地址:http://www.cnblogs.com/lukcyjane/p/3850033.html