2 gwolf fuhaitao Gwolf_Fuhaitao 于 2014.02.17 13:42 提问

python调用存储过程怎么总是返回none

DROP TABLE IF EXISTS status_201402;
CREATE TABLE status_201402 (
StatusID int(4) NOT NULL AUTO_INCREMENT,
DriveID int(4) DEFAULT NULL,
InsID int(4) DEFAULT NULL,
StatusTime datetime DEFAULT NULL,
StatusParam double DEFAULT NULL,
PRIMARY KEY (StatusID)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

/*******************创建存储过程******************/

CREATE PROCEDURE test(IN DriveID1 int,IN InsAddress1 int,IN StatusTime1 datetime,IN StatusParam1 float)
BEGIN
INSERT INTO status_201402(DriveID,InsID,StatusTime,StatusParam)VALUES(DriveID1,InsAddress1,StatusTime1,StatusParam1);
END

/*******************python脚本******************/

#_*_coding:utf-8_*_

import MySQLdb
import time
conn=MySQLdb.connect(host='192.168.0.129',port=3306,user='hello',passwd='274348',charset="utf8",db="hjjk")
cur=conn.cursor()
#cur.callproc('AddStatus',(1,3,time.strftime('%Y-%m-%d %H:%M:%S'),7))
#cur.callproc('AddStatus',(1,3,'2014-02-14 16:19:00',7))
cur.callproc('test',(1,3,'2014-02-14 16:19:00',8))
cur.execute('select @_DriveID,@_InsAddress,@_StatusTime,@_StatusParam')
data=cur.fetchall()
cur.close()
conn.close()

利用python执行存储过程返回None

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!