这是我的删除下载功能。我下载表中的id字段设置为自动增量。当id值小于10时,此函数似乎工作正常。一旦值为10或更大,cursor.execute()就会失败。
def remove_download(id, userName):
db = threadpool.connect()
if db is not None:
cursor = db.cursor()
sql1 ="SELECT status FROM download WHERE id=%s;"
sql = "DELETE from download WHERE id=%s and user_name=%s;"
try:
cursor.execute(sql1,str(id))
data = cursor.fetchone()
if data[0] != Status.DEFAULT and data[0] != Status.ERROR:
db.commit()
return "Download started. Entry cannot be deleted."
cursor.execute(sql, (str(id), userName))
db.commit()
except MySQLdb.Error as e:
db.rollback()
return e[1]
return "success"
return "db connection error"