![](/img/trans.png)
[英]Getting “Not all parameters were used in the SQL statement” error, when trying to import data to MySQL using python
[英]Not all parameters were used in the SQL statement while trying to insert into mysql database using flask application
error image Actually I am trying to create flask web application in which, I wanted to store my input values from html webpage into MySQL database, but am getting error as Not all parameters were used in the SQL statement when calling my insert function. 請找到我的代碼
import mysql.connector as conn
def insert_records(name,email,location,salary,band):
con=conn.connect(host='localhost',user='root',password='my password',database="my database")
cur=con.cursor()
sql="""insert into emp1.emp(Name,Email,Location,Salary,Band) values (%s,%s,%s,%d,%s)"""
val=(name,email,location,salary,band)
cur.execute(sql,val)
con.commit()
con.close()
您需要對文檔中的每個參數使用 %s - 他們將 %s 用於字符串、整數、日期時間等。
https://dev.mysql.com/doc/connector-python/en/connector-python-api-mysqlcursor-execute.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.