自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Python連接SqlServer基本應(yīng)用方式淺析

開發(fā) 后端
Python連接SqlServer這一操作技術(shù)在實(shí)際程序開發(fā)中是一個(gè)比較常用到的操作技術(shù)。我們?cè)谶@里先為大家介紹一下這一操作的基本方式,以方便理解。

Python編程語言簡(jiǎn)單易用,很方便開發(fā)人員快速學(xué)習(xí)使用。而且其應(yīng)用范圍也比較廣泛。我們今天就先來一起看看有關(guān)Python連接SqlServer的一些基本應(yīng)用方式,以此來滿足我們對(duì)這方面的學(xué)習(xí)需要。

Python連接SqlServer代碼示例:

  1. import pymssql   
  2. #connect database  
  3. conn=pymssql.connect(host="192.168.1.28",user="boomink",
    password="boomink",database="boomink")   
  4. cur=conn.cursor()   
  5. print '========================================'   
  6. cur.execute("exec Orders_GetTest1 @Value=%s ",('2005-01-01',))   
  7. while 1:  
  8. print cur.fetchall()  
  9. if 0 == cur.nextset():  
  10. break   
  11. data=cur.fetchall()   
  12. print data   
  13. print '========================================'   
  14. #cur.execute("exec Orders_GetTest")  
  15. cur.execute("exec Orders_GetTest2 @Value1=%s,@Value2=%s",('Ruan','Yu'))   
  16. while 1:  
  17. print cur.fetchall()  
  18. if 0 == cur.nextset():  
  19. break   
  20. data=cur.fetchall()   
  21. print data   
  22. print '========================================'   
  23. cur.execute("exec Orders_GetTracking @BeginDate=%s,
    @
    EndDate=%s",('2005-01-01','2008-01-01'))   
  24. record = cur.fetchall()  
  25. while 1:  
  26. print cur.nextset()  
  27. for r in record:   
  28. print '========================================'  
  29. a=r[1]   
  30. print 'OrderId:%s' % r[0]   
  31. print r   
  32. print '========================================'  
  33. if 0 == cur.nextset():  
  34. break  
  35. print "rnrow count:%d" % cur.rowcount  
  36. #commit the connection  
  37. conn.commit  
  38. #close the connection  
  39. conn.close  

以上就是對(duì)Python連接SqlServer的相關(guān)介紹。

【編輯推薦】

  1. Python數(shù)組功能特點(diǎn)分析
  2. Python實(shí)現(xiàn)網(wǎng)頁(yè)爬蟲基本實(shí)現(xiàn)代碼解讀
  3. 深度講述Python標(biāo)準(zhǔn)語言特性
  4. 深度剖析Python語言?shī)W秘
  5. 探秘簡(jiǎn)單強(qiáng)大的Python語言
責(zé)任編輯:曹凱 來源: 博客園
相關(guān)推薦

2010-03-03 16:40:55

Python HTTP

2010-03-03 14:30:05

Python set類

2010-03-03 14:40:37

Python打包方法

2010-03-04 09:27:34

調(diào)用Python腳本

2010-03-03 16:08:26

Python取得文件列

2010-03-03 15:17:46

Python調(diào)用MyS

2010-02-02 14:45:35

C++ typeof

2013-12-12 16:10:21

Lua腳本語言

2010-03-03 13:22:08

Python正則表達(dá)式

2010-01-25 13:45:04

Android單選框

2010-06-23 15:28:22

2010-02-02 17:33:17

C++友元函數(shù)

2010-03-04 14:57:08

Python解密VBS

2010-07-08 15:24:17

SNMP trap

2010-03-05 15:47:59

Python Stri

2010-03-04 15:52:59

Python構(gòu)造列表

2010-02-04 17:16:33

C++調(diào)用python

2010-03-03 13:32:08

Python壓縮文件

2010-02-25 10:52:29

WCF響應(yīng)服務(wù)

2010-02-26 13:40:28

WCF消息頭
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)