为什么我的 SQL INSERT INTO 语句会直接出错?
我正在创建一个登录系统,但是插入语句中的插入不起作用。我以前已经使用过此代码&它运行得很好,但是当我运行它时,它直接进入“插入错误”。有什么想法,为什么这可能是?
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 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论