Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MySQL函数在Aurora中工作,但不';我不能完全使用python脚本_Mysql_Python 3.x - Fatal编程技术网

MySQL函数在Aurora中工作,但不';我不能完全使用python脚本

MySQL函数在Aurora中工作,但不';我不能完全使用python脚本,mysql,python-3.x,Mysql,Python 3.x,我已经编写了基本排队函数,它返回最早使用的API凭据。它在数据库中工作得很好,但当我在python中调用它时,它返回正确的凭据,但它不会更新last_used字段上次使用的是日期时间类型。也许这是一些琐碎的事情,但我不知道会出什么问题。 MySQL: create definer = admin@`%` function getAPICredentials() returns varchar(400) begin DECLARE id VARCHAR(20

我已经编写了基本排队函数,它返回最早使用的API凭据。它在数据库中工作得很好,但当我在python中调用它时,它返回正确的凭据,但它不会更新last_used字段上次使用的是日期时间类型。也许这是一些琐碎的事情,但我不知道会出什么问题。
MySQL:

create
        definer = admin@`%` function getAPICredentials() returns varchar(400)
    begin
        DECLARE id VARCHAR(200) DEFAULT '';
        DECLARE password VARCHAR(200) DEFAULT '';
    
        SELECT `client-id`,`secret` into id,password from `api-credentials` as api order by `last_used` LIMIT 1;
    
        UPDATE `api-credentials` set `last_used` = NOW() WHERE `client-id` = id;
    
        return CONCAT(id,',',password);
    
    end;
    def getAPICredentials(self):
        database = self.openConnection()
        cursor = database.cursor()
        cursor.execute("SELECT getAPICredentials();")
        result = cursor.fetchone()
        cursor.close()
        database.close()
    
        if len(result) > 0:
            return result[0]
        else:
            return None


Python:

create
        definer = admin@`%` function getAPICredentials() returns varchar(400)
    begin
        DECLARE id VARCHAR(200) DEFAULT '';
        DECLARE password VARCHAR(200) DEFAULT '';
    
        SELECT `client-id`,`secret` into id,password from `api-credentials` as api order by `last_used` LIMIT 1;
    
        UPDATE `api-credentials` set `last_used` = NOW() WHERE `client-id` = id;
    
        return CONCAT(id,',',password);
    
    end;
    def getAPICredentials(self):
        database = self.openConnection()
        cursor = database.cursor()
        cursor.execute("SELECT getAPICredentials();")
        result = cursor.fetchone()
        cursor.close()
        database.close()
    
        if len(result) > 0:
            return result[0]
        else:
            return None