需要pymssql模块
模块下载地址:http://pymssql.sourceforge.net/
例子:
import pymssql
con=pymssql.connect(host='127.0.0.1',user='sa',password='',database='dbname')
cur=con.cursor()
cur.execute('select count(*) from bokewu_table')
for i in cur.fetchall():
for j in i
print j #为什么这里用2次for ,是因为能让中文完整的显示,我就是因为这里少一次循环而整了半天不能显示中文
print cur.fetchall()
cur.close()
con.close()
con=pymssql.connect(host='127.0.0.1',user='sa',password='',database='dbname')
cur=con.cursor()
cur.execute('select count(*) from bokewu_table')
for i in cur.fetchall():
for j in i
print j #为什么这里用2次for ,是因为能让中文完整的显示,我就是因为这里少一次循环而整了半天不能显示中文
print cur.fetchall()
cur.close()
con.close()
