Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

PythonÁ¬½ÓSqlServerÁ·Ï°¼Ç¼


import pymssql

#connect database
conn=pymssql.connect(host="192.168.1.28",user="boomink",password="boomink",
database="boomink")

cur=conn.cursor()

print '========================================'

cur.execute("exec Orders_GetTest1 @Value=%s ",('2005-01-01',))

while 1:
print cur.fetchall()
if 0 == cur.nextset():
break

data=cur.fetchall()

print data

print '========================================'

#cur.execute("exec Orders_GetTest")
cur.execute("exec Orders_GetTest2 @Value1=%s,@Value2=%s",('Ruan','Yu'))

while 1:
print cur.fetchall()


if 0 == cur.nextset():
break

data=cur.fetchall()

print data

print '========================================'

cur.execute("exec Orders_GetTracking @BeginDate=%s,@EndDate=%s",('2005-01-01','2008-01-01'))

record = cur.fetchall()
while 1:
print cur.nextset()

for r in record:
print '========================================'
a=r[1]
print 'OrderId:%s' % r[0]

print r
print '========================================'

if 0 == cur.nextset():
break
print "rnrow count:%d" % cur.rowcount
#commit the connection
conn.commit
#close the connection
conn.close


Ïà¹ØÎĵµ£º

sqlserver ÆÚÖп¼ÊÔÌâ

 create database DB
use DB
--רҵ±í
create table major
(spno char(5) not null primary key,
 spname varchar(20) not null,
 pno char(2) )
--ѧÉú±í
create table student
(sno char(7) not null primary key,
 sname varchar(20) not null,
 ssex char(2) not null,
 sag ......

ÔÚSqlServer´æ´¢¹ý³ÌÖÐʹÓÃCursor£¨Óα꣩²Ù×÷¼Ç¼

 
1. ΪºÎʹÓÃÓα꣺
    
ʹÓÃÓαê(cursor)µÄÒ»¸öÖ÷ÒªµÄÔ­Òò¾ÍÊǰѼ¯ºÏ²Ù×÷ת»»³Éµ¥¸ö¼Ç¼´¦Àí·½Ê½¡£ÓÃSQLÓïÑÔ´ÓÊý¾Ý¿âÖмìË÷Êý¾Ýºó£¬½á¹û·ÅÔÚÄÚ´æµÄÒ»¿éÇøÓòÖУ¬ÇÒ½á¹û
ÍùÍùÊÇÒ»¸öº¬Óжà¸ö¼Ç¼µÄ¼¯ºÏ¡£Óαê»úÖÆÔÊÐíÓû§ÔÚSQL serverÄÚÖðÐеطÃÎÊÕâЩ¼Ç¼£¬°´ÕÕÓû§×Ô¼ºµÄÒâÔ¸À´ÏÔʾºÍ´¦ÀíÕ ......

sqlserver ´æ´¢¹ý³ÌÀý×Ó

 Ê²Ã´ÊÇ´æ´¢¹ý³ÌÄØ£¿
¡¡¡¡¶¨Ò壺
¡¡¡¡½«³£ÓõĻòºÜ¸´ÔӵŤ×÷£¬Ô¤ÏÈÓÃSQLÓï¾äдºÃ²¢ÓÃÒ»¸öÖ¸¶¨µÄÃû³Æ´æ´¢ÆðÀ´, ÄÇôÒÔºóÒª½ÐÊý¾Ý¿âÌṩÓëÒѶ¨ÒåºÃµÄ´æ´¢¹ý³ÌµÄ¹¦ÄÜÏàͬµÄ·þÎñʱ,Ö»Ðèµ÷ÓÃexecute,¼´¿É×Ô¶¯Íê³ÉÃüÁî¡£
¡¡¡¡½²µ½ÕâÀï,¿ÉÄÜÓÐÈËÒªÎÊ£ºÕâô˵´æ´¢¹ý³Ì¾ÍÊÇÒ»¶ÑSQLÓï¾ä¶øÒÑ°¡£¿
¡¡¡¡Microsoft¹«Ë¾ÎªÊ²Ã´»¹ ......

PythonÍêÈ«ÐÂÊֽ̳Ì

×÷Õߣºtaowen, billrice
http://www.cnblogs.com/taowen/articles/11239.html
Lesson 1 ×¼±¸ºÃѧϰPythonµÄ»·¾³
ÏÂÔصĵØÖ·ÊÇ£º
www.python.org
ΪÁË´ó¼ÒµÄ·½±ã£¬ÎÒÔÚУÄÚ×÷ÁËcopy£º
http://10.1.204.2/tool/compiler&IDE/Python-2.3.2-1.exe
linux°æ±¾µÄÎҾͲ»ËµÁË£¬ÒòΪÈç¹ûÄãÄܹ»Ê¹ÓÃlinux²¢°²×°ºÃ˵Ã÷Äã¿ÉÒÔ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ