Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从python插入数据后未更新SQLite数据库_Python_Sql_Python 3.x_Sqlite_Flask - Fatal编程技术网

从python插入数据后未更新SQLite数据库

从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

我在Flask web应用程序中有一个应用程序路由,该应用程序使用“POST”方法从网站表单中获取数据,并应该向SQLite数据库(database.db)中添加一个条目,该条目的信息在表“times”中。代码运行时不会调用任何错误,但数据库不会使用添加的条目进行更新。Flask应用程序从表单中正确检索信息。这是我连接数据库并尝试更新它的代码。我做错什么了吗

    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中