我遇到了问题,每当我试图运行下面的代码,选择语句2来,插入一个工具并放置一个随机的工具名,我就会得到错误消息:ProgrammingError(‘列“插入工具’不存在\n行1: insert tools(tool_name,rental_days)值(@insertTool,'2')。
以下是代码:
if Menu == "2":
cursor = connection.cursor()
InsertTool = raw_input("Please insert the tool that you want to add.\n")
insert_tool = """insert into tools(tool_name, rental_days) values(@InsertTool, '2')"""
try:
cursor.execute( insert_tool);
connection.commit();
print("Tool is succesfully inserted!")
except Exception as e:
connection.rollback();
print("Exception Occured : ",e)
connection.close(); 发布于 2019-11-29 06:05:25
尝尝这个。
if Menu == "2":
cursor = connection.cursor()
InsertTool = raw_input("Please insert the tool that you want to add.\n")
insert_tool = """insert into tools(tool_name, rental_days) values(%s, %s)"""
val = (InsertTool, "2")
try:
cursor.execute(insert_tool, val);
connection.commit();
print("Tool is succesfully inserted!")
except Exception as e:
connection.rollback();
print("Exception Occured : ",e)
connection.close();https://stackoverflow.com/questions/59099440
复制相似问题