我找不到问题:
@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()
错误:
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 文件中使用姓名、电子邮件用户名和密码?我该如何解决?
最佳答案
在您连接到数据库的地方添加以下内容。
conn = sqlite3.connect('your.db', check_same_thread=False)
关于python - 在一个线程中创建的对象只能在同一个线程中使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48218065/