复制代码 代码如下: #!/usr/bin/env python # -*- coding: utf8 -*- import MySQLdb import time import os,sys,string def CallProc(id,onlinetime): '''调用存储过程, 输入参数:编号,在线时间,输出:帐号,密码; 使用输出参数方式''' accname='' accpwd='' conn = MySQLdb.connect(host='localhost',user='root',passwd='222221',db='ceshi') cur =conn.cursor() cur.callproc('proctest',(id,onlinetime,accname,accpwd)) cur.execute('select @_proctest_2,@_proctest_3') data=cur.fetchall() if data: for rec in data: accname=rec[0] accpwd=rec[1] cur.close() conn.close(); return accname,accpwd def CallProct(id,onlinetime): '''调用存储过程, 输入参数:编号,在线时间,输出:帐号,密码; 使用select返回记录方式''' accname='' accpwd='' conn = MySQLdb.connect(host='localhost',db='ceshi') cur =conn.cursor() cur.nextset() cur.execute('call ptest(%s,%s)',onlinetime)) data=cur.fetchall() if data: for rec in data: accname=rec[0] accpwd=rec[1] cur.close() conn.close(); return accname,accpwd name,pwd=CallProct(1,0) print name,pwd
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|