Python存储过程未运行,没有错误

时间:2016-08-28 19:19:06

标签: python mysql stored-procedures

以下过程可以从mysql客户端正常工作,但不能从Python运行。

存储过程

CREATE DEFINER=`music-cnv`@`%` PROCEDURE `StoreFileStats`(FNAME VARCHAR(200), FEXT varchar(4), FBDIR VARCHAR(100), FRDIR VARCHAR(250), FSIZE bigint(8), FMDATE bigint(8), FCDATE bigint(8), CONVERTED tinyint(1))
BEGIN
    DECLARE FCount int DEFAULT 0;
    SELECT COUNT(FileName) INTO FCount FROM FileList where (FleRelativeDir LIKE FRDIR) AND (FileName LIKE FNAME);
    IF FCount = 0 THEN 
        INSERT INTO FileList (FileName,FileBaseDir,FleRelativeDir,FileExt,FileSize,FileModDate,FileCDate,Con#verted) VALUES (FNAME,FBDir,FRDir,FEXT,FSize,FMDate,FCDate,CONVERTED);
    END IF;
END

数据

'In the Light', 'FLAC', '/var/data/Music_FLAC', 'Led Zeppelin/Physical Graffiti, Disc 2', 51472669, 1289282499, 1458631127, False

Python代码

连接和游标没有错误

try:
    myargs = [fnamesub, self.type.strip(), self.directory,
        subdirname, fpathstat[2], fpathstat[3],
        fpathstat[4], False]
    result_args = mycur.callproc('StoreFileStats', myargs)
except mysql.connector.Error as Err:
    errno = 51
    print('Error ' + str(errno) + ' !!!, Cannot Update MySQL Data with    Name    '     + fnamesub)
    print(Err)

代码运行时没有错误但不更新数据库 感谢您的帮助

1 个答案:

答案 0 :(得分:0)

只需提交。从shell自动提交运行过程时启用。但是从Python运行时必须手动运行commit。