1 year ago

#388394

test-img

Ela

Why is my SQL INSERT INTO statement going straight to error?

I am creating a login system but the INSERT INTO statement isn't working. I have used this code previously & it has worked perfectly, however when I run this it goes straight to "ERROR IN INSERTION". Any ideas why this might be?

loginDb = sqlite3.connect("loginTable.db")
loginConnect = loginDb.cursor()
print ("Login System Accessed")

try:
        nameInput = request.form["username"]
        passwordInput = request.form["password"]
        confirmpassInput = request.form["confirmPass"]
        emailInput = request.form["email"]

        loginConnect.execute("INSERT INTO login (username, password, email) VALUES (?,?,?)", (nameInput, passwordInput, emailInput))
        loginDb.commit()
        msg = "Record successfully added"
except:
        msg = "Error in insertion"

finally:
        return render_template("newResults.html", msg = msg)
        loginDb.close()

I have tried to test if it just isn't accessing the database but that didn't show any errors & printed the database perfectly. I have also tested if it isn't collecting the form entries but that also prints perfectly.

python

sqlite

sql-insert

0 Answers

Your Answer

Accepted video resources