Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.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
Python3 MySQL查找行数错误?_Python_Mysql_Python 3.x - Fatal编程技术网

Python3 MySQL查找行数错误?

Python3 MySQL查找行数错误?,python,mysql,python-3.x,Python,Mysql,Python 3.x,我尝试了几种不同的方法,因此我来这里寻求指导。这哪里不正确 with connection.cursor() as cur: sql = 'select * from table where var1 = %s, var2 = %s, var3 = %s, var4 = %s, var5 = %s' cur.execute(sql, (var1val, var2val, var3val, var4val, var5val)) connection.comm

我尝试了几种不同的方法,因此我来这里寻求指导。这哪里不正确

with connection.cursor() as cur:
    sql = 'select * from table where var1 = %s, var2 = %s, var3 = %s, var4 = %s, var5 = %s'
        cur.execute(sql, (var1val, var2val, var3val, var4val, var5val))
        connection.commit()
        l_fetch = cur.fetchall()
        rc = int(l_fetch.rowcount)
        print('rc len lerr_log: ' + rc)
        if(rc > 0):
            #result found
cur.fetchall()
返回一个列表,它没有
rowcount
属性


行数为
cur.rowcount
len(l_fetch)

我认为您不需要
connection.commit()
对于
选择
查询,只需要进行更改的查询。