从python插入数据后未更新SQLite数据库
我在Flask web应用程序中有一个应用程序路由,该应用程序使用“POST”方法从网站表单中获取数据,并应该向SQLite数据库(database.db)中添加一个条目,该条目的信息在表“times”中。代码运行时不会调用任何错误,但数据库不会使用添加的条目进行更新。Flask应用程序从表单中正确检索信息。这是我连接数据库并尝试更新它的代码。我做错什么了吗从python插入数据后未更新SQLite数据库,python,sql,python-3.x,sqlite,flask,Python,Sql,Python 3.x,Sqlite,Flask,我在Flask web应用程序中有一个应用程序路由,该应用程序使用“POST”方法从网站表单中获取数据,并应该向SQLite数据库(database.db)中添加一个条目,该条目的信息在表“times”中。代码运行时不会调用任何错误,但数据库不会使用添加的条目进行更新。Flask应用程序从表单中正确检索信息。这是我连接数据库并尝试更新它的代码。我做错什么了吗 connection=sqlite3.connect("database.db") cursor=connection.c
connection=sqlite3.connect("database.db")
cursor=connection.cursor()
cursor.execute("INSERT INTO times (firstname, lastname, year, gender, event, minutes, seconds, milliseconds, date) VALUES(:first, :last, :year, :gender, :event, :minutes, :seconds, :milliseconds, :date)",
dict(first=first, last=last, year=year, gender=gender, event=event, minutes=minutes, seconds=seconds, milliseconds=milliseconds, date=date))
return redirect("/")
缺少连接。提交()
请将其添加到execute语句之后,以将条目保存在DB中。缺少
connection.commit()
请将其添加到execute语句之后,以将条目保存在DB中