且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

错误:1210:执行准备好的语句的参数数量不正确

更新时间:2023-11-08 18:27:52

您忘记了传递

MySQLCursor.executemany()方法 语法:

MySQLCursor.executemany() Method Syntax:

cursor.executemany(operation, seq_of_params)

此方法准备数据库操作(查询或命令),并针对序列seq_of_params中找到的所有参数序列或映射执行该操作.

This method prepares a database operation (query or command) and executes it against all parameter sequences or mappings found in the sequence seq_of_params.

同样,您的语法错误(删除引号),请改用以下内容:

Also your syntax is wrong (remove quotes), use the following instead:

records_to_insert = [('---2q7vcZGU', 'Partner-provided', '35', '9s1Pvm0U8Gg8mRavZhVXdg', 'A663893851990558', '1066/2016/HDHT-Pops-Kha Ly', '1467', '0.100598')]
sql_insert_query = "INSERT INTO raw_music (`Video_ID`, `Content_Type`, `Video_Duration`, `Channel_ID`, `Asset_ID`, `Asset_Labels`, `Owned_Views`, `Partner_Revenue`) VALUES ( %s, %s , %s , %s, %s , %s , %s , %s) "
cursor = connection.cursor(prepared=True)
result  = cursor.executemany(sql_insert_query, records_to_insert)