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
相关文档:
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 ......
作者: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并安装好说明你可以 ......
以下内容转载自javaeye.com的作者bluecrystal
环境说明:以下python代码均在python2.5下通过。
最近看到一些人在讨论python中类属性和类的实例的属性,我也来谈谈我个人对这个问题的看法,供pyer参考。
首先我们来简单的定义一个python的类:
Python代码
# coding:  ......
>>> import copy
>>> a = [1,2,3,4,['a','v']]
>>> b = a
>>> b
[1, 2, 3, 4, ['a', 'v']]
>>> c = copy.copy(a)
>>> c
[1, 2, 3, 4, ['a', 'v']]
>>> d = copy.deepcopy(a)
>>> d
[1, 2, 3, 4, ['a', 'v']]
>>> a.append(5) ......