from adodbapi import connect
inters='SSPI' PSI='False' database='test' datasource=r'Angela\SQLT'
try: db=connect('Provider=SQLOLEDB.1;Data Source=%s;Initial Catalog=%s;\ Integrated Security=%s;Persist Security Info=%s;'%(server, database, inters, PSI))
except Exception,e: print e else: cur=db.cursor() msg=cur.exec("select * from user_info2") print msg
db.close()
|
上面的实例是用python连接sql server数据库,并执行相关查询语句。
阅读(695) | 评论(0) | 转发(0) |