DB. Browser.Sqlite.OperationalError: database is locked
DB. Browser.Sqlite.OperationalError: database is locked
我正在尝试将表单提交到 DB Browser Sqlite。我创建了一个 table。我能够将数据存储到 Sqlite 中。但是,一旦我添加了一个函数来在提交按钮 (submitclaim.html) 中执行一个确认弹出框,我就显示了这个错误
sqlite3.OperationalError: database is locked
当我尝试向 table 提交表单时,它发生在以下行:
c.execute("INSERT INTO SubmitClaim VALUES (?,?,?,?,?)", (depart, type, uploadre, amt, description)
这是我的app.py
@app.route('/addrec', methods=['POST', 'GET'])
def addrec():
if request.method == 'POST':
depart = request.form['depart']
type = request.form['type']
uploadre = request.form['uploadre']
amt = request.form['amt']
description = request.form['description']
conn = sql.connect(db_path)
c = conn.cursor()
c.execute(
"INSERT INTO SubmitClaim VALUES (?,?,?,?,?)", (depart, type, uploadre, amt, description))
conn.commit()
c.execute("SELECT * FROM SubmitClaim")
print(c.fetchall())
conn.close()
return render_template('base.html', user=session["user"], version=msal.__version__)
这是我的SubmitClaim.html
<div class="arrange3">
<button onclick="myFunction()" type="submit" class="submit-button" name="save", value="save">Submit</button>
<script>
function myFunction() {
confirm("Press a button!");
}
您只需在 DB Browser SQLITE 中关闭数据库并运行代码
我正在尝试将表单提交到 DB Browser Sqlite。我创建了一个 table。我能够将数据存储到 Sqlite 中。但是,一旦我添加了一个函数来在提交按钮 (submitclaim.html) 中执行一个确认弹出框,我就显示了这个错误
sqlite3.OperationalError: database is locked
当我尝试向 table 提交表单时,它发生在以下行:
c.execute("INSERT INTO SubmitClaim VALUES (?,?,?,?,?)", (depart, type, uploadre, amt, description)
这是我的app.py
@app.route('/addrec', methods=['POST', 'GET'])
def addrec():
if request.method == 'POST':
depart = request.form['depart']
type = request.form['type']
uploadre = request.form['uploadre']
amt = request.form['amt']
description = request.form['description']
conn = sql.connect(db_path)
c = conn.cursor()
c.execute(
"INSERT INTO SubmitClaim VALUES (?,?,?,?,?)", (depart, type, uploadre, amt, description))
conn.commit()
c.execute("SELECT * FROM SubmitClaim")
print(c.fetchall())
conn.close()
return render_template('base.html', user=session["user"], version=msal.__version__)
这是我的SubmitClaim.html
<div class="arrange3">
<button onclick="myFunction()" type="submit" class="submit-button" name="save", value="save">Submit</button>
<script>
function myFunction() {
confirm("Press a button!");
}
您只需在 DB Browser SQLITE 中关闭数据库并运行代码