为什么我的 SQL INSERT INTO 语句会直接出错?

发布于 2025-01-19 19:27:40 字数 836 浏览 1 评论 0原文

我正在创建一个登录系统,但是插入语句中的插入不起作用。我以前已经使用过此代码&它运行得很好,但是当我运行它时,它直接进入“插入错误”。有什么想法,为什么这可能是?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文