1

I have an app route in a Flask web application, which under the "POST" method, takes data from a website form and is supposed to add an entry into a SQLite database (database.db) with that info in the table 'times'. The code runs without invoking any errors, but the database does not update with the added entry. The Flask app properly retrieves the info from the form. This is my code for connecting to the database and attempting to update it. Am I doing anything wrong?

    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("/")

1 Answer 1

2

Missing connection.commit().

Please add that after the execute statement to save the entry in DB.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.