python连接mysql调用存储过程示例
2014-03-05 00:00
841 查看
#!/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',user='root',passwd='111111',db='ceshi') cur =conn.cursor() cur.nextset() cur.execute('call ptest(%s,%s)',(id,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存储过程进行调用
- Node.js中调用mysql存储过程示例
- Node.js中调用mysql存储过程示例
- Python简单调用MySQL存储过程并获得返回值的方法
- python2.7调用mysql存储过程并且返回结果
- MySQL存储过程相互调用并获得错误码示例
- python 调用mysql存储过程返回结果集
- Python对MySQL存储过程的调用
- Python简单调用MySQL存储过程并获得返回值的方法
- 关于ADO连接MYSQL调用存储过程的ERROR1064错误
- python 调用mysql存储过程返回结果集
- MySql 存储过程使用游标循环插入数据示例
- SQL Server 2000 通用单表或视图查询存储过程及C#调用示例
- Java调用Oracle、mysql带out参数的存储过程
- JSP调用Mysql存储过程的方法和例子
- PHP调用MYSQL存储过程实例
- mysql 存储过程游标的使用及存储过程调用存储过程
- jdbc调用mysql存储过程,并获得结果集合
- hibernate调用mysql存储过程