Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/64.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
Python pymysql.err.OperationalError:(1241,';操作数应包含1列';)。我能';我不能判断一个错误_Python_Mysql_Pymysql - Fatal编程技术网

Python pymysql.err.OperationalError:(1241,';操作数应包含1列';)。我能';我不能判断一个错误

Python pymysql.err.OperationalError:(1241,';操作数应包含1列';)。我能';我不能判断一个错误,python,mysql,pymysql,Python,Mysql,Pymysql,我无法确定此代码中的错误到底是什么。在values子句中有以下子查询: with connection: with connection.cursor() as cursor: window = Tk() window.title('Data change') window.geometry('500x300') title1 = input('Name of film: ') country1 = input('Country: ') yea

我无法确定此代码中的错误到底是什么。

在values子句中有以下子查询:

with connection:  
with connection.cursor() as cursor:
    window = Tk()
    window.title('Data change')
    window.geometry('500x300')
    title1 = input('Name of film: ')
    country1 = input('Country: ')
    year1 = int(input('Year: '))
    duration1 = int(input('Duration: '))
    clicked2 = input('Genre: ')
    clicked3 = int(input('Director ID: '))

    sql = """insert into Film(director_id, title, genre, year, country, duration_in_min) values((select * from Director where Id = %s),%s, %s, %s, %s, %s);"""
    var = (title1, clicked2, year1, country1, duration1, clicked3)
    cursor.execute(sql, var)
    connection.commit()
此子查询可能返回多个列,从而触发错误消息。您应该只选择1列,或者直接使用director id而不使用子查询


参数的顺序与插入的字段列表中字段的顺序不匹配。例如,insert中的第一个字段是
director\u id
,但您正在参数数组的第一个位置传递
title1
参数。

谢谢,我已修复了此错误,它正在工作。
(select * from Director where Id = %s)