【发布时间】:2020-08-26 06:10:09
【问题描述】:
我想使用准备好的语句从表中删除一行,但是会导致错误:mysql.connector.errors.ProgrammingError: Not all parameters were used in the SQL statement
相关代码:
db = mysql.connector.connect(
host='localhost',
user='user',
database='web_board',
password='password',
auth_plugin='mysql_native_password'
)
crs = db.cursor()
# construct the query and remove post from the database
query = 'DELETE FROM posts WHERE postid=%s'
crs.execute(query, tuple(request.data))
db.commit()
crs.close()
db.close()
request.data 看起来像这样:b'9b23f24e-ff4d-4113-85ae-ff8a4a5de3be'
【问题讨论】:
标签: python mysql python-3.x prepared-statement mysql-python