用户工具

站点工具


doc:n:python_mssql_2005

使用Python访问MSSQL 2005

环境
1 MSSQL 2005 Enterprise Edition on Windows 2003 R3 I386
2 FreeBSD 7.0 Beta4
安装MSSQL 2005

略(参考MS XX文档)

安装Python
#cd /usr/ports/lang/python25
#make 
#make install
安装FreeTDS 0.64_1
#cd /usr/ports/datebases/freetds-msdblib
#make 
#make install

配置freetds.conf

[root@bsdx64]#cat /usr/local/etc/freetds.conf
dump file = /tmp/freetds.log
[MyServer2k]
       host = 192.168.0.75
       port = 1433
       tds version = 8.0
       Database = testdb
安装py-mssql
#cd /usr/ports/databases/py-mssql
#make 
#make install
测试

编辑py_mssql_test.py

import _mssql
on = _mssql.connect("MyServer2k","yarshure","123456")
con.select_db("AdventureWorks")
con.query("select top 5 * from [Person].[Address]")
row=con.fetch_array()
print row
/data/vhosts/wiki-data/pages/doc/n/python_mssql_2005.txt · 最后更改: 2007/12/14 12:28 由 yarshure