python 利用pymssql连接MSSQL数据库,简单示例

 1 #-*- coding:GBK -*-
 2 
 3 
 4 import pymssql
 5 print 'Connect to the Datebase....'
 6 
 7 conn = pymssql.connect(host='127.0.0.1' ,user='999' ,password = '',database='drp')
 8 
 9 cur = conn.cursor()
10 if not cur:
11     raise(NameError,'connect failed')
12     
13 
14 cur.execute('select * From lrkjqj')
15 
16 row = cur.fetchone()
17 print row
18 while row:
19     print row[0],row[1]
20     row = cur.fetchone()
21 conn.close()
原文地址:https://www.cnblogs.com/lrzy/p/4346919.html