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
相关文档:
今天在写视图时,遇到要把Datetime类型转Varchar类型。以前在ORALCE就容易,直接ToChar(getdate(),'yyyy-mm-dd')。在SQL Server 2005
select CONVERT(varchar, getdate(), 120 )
2004-09-12 11:06:08
select CONVERT(varchar(12) , getdate(), 111 )
2004/09/12
select CONVERT(varchar(12) , getdate(), 112 )
200 ......
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 ......
Python 3 教程二:文件,目录和路径
http://www.cnitblog.com/yunshichen/archive/2009/04/01/55931.html
python os模块
http://hi.baidu.com/happynp/blog/item/729243f902d5a751242df2c2.html
http://hi.baidu.com/fiber212121/blog/item/6e07ec03c97b6982d53f7c27.html
python getopt模块
http://www.tsnc.edu.cn/de ......