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()

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM