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