ProgrammingError:在线程中创建的SQLite对象只能在同一线程中使用
发布于 2021-01-29 18:40:38
我是编程新手。我以前尝试过MySQL,但现在是我第一次在python
flask网站上使用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文件中使用名称,电子邮件用户名和密码?我该如何解决?
谢谢。
关注者
0
被浏览
167
1 个回答