MsSQL   发布时间:2022-05-16  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了python连接mysql调用存储过程示例大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

复制代码 代码如下:

#!/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='111111',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

大佬总结

以上是大佬教程为你收集整理的python连接mysql调用存储过程示例全部内容,希望文章能够帮你解决python连接mysql调用存储过程示例所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:sys