【发布时间】:2018-06-21 10:22:19
【问题描述】:
我对编程很陌生。我以前尝试过 MySQL,但现在这是我第一次在 python 烧瓶网站中使用 SQLite。 所以也许我使用的是 MySQL 语法而不是 SQLite,但我似乎找不到问题。
Piece of my code:
@app.route('/register', methods=['GET', 'POST'])
def register():
form = RegisterForm(request.form)
if request.method=='POST' and form.validate():
name = form.name.data
email = form.email.data
username = form.username.data
password = sha256_crypt.encrypt(str(form.password.data))
c.execute("INSERT INTO users(name,email,username,password)
VALUES(?,?,?,?)", (name, email, username, password))
conn.commit
conn.close()
The error:
File "C:\Users\app.py", line 59, in register c.execute("INSERT INTO users(name,email,username,password) VALUES(?,?,?,?)", (name, email, username, password))
ProgrammingError: SQLite objects created in a thread can only be used in that
same thread.The object was created in thread id 23508 and this is thread id
22640
这是否意味着我不能在 HTML 文件中使用姓名、电子邮件用户名和密码? 我该如何解决这个问题?
谢谢。
【问题讨论】:
-
不,它们显然是定义在它上面的 python 对象。错误消息涉及连接和光标。