SQLite3 - UPDATE查询后数据库被锁定

时间:2016-02-09 16:16:31

标签: python flask sqlite sql-update pycharm

我在Flask中编写了以下代码,以便我更新存储的特定用户/患者的地址。但是,一旦表单提交,我就会收到错误:' sqlite3.OperationalError:数据库被锁定'。

非常感谢任何帮助。

@app.route('/portal/<username>/edit', methods=['GET', 'POST'])
def edit(username):

    logged_in_as = session['username']
    g.db = connect_db()
    cursor = g.db.cursor()
    if request.method == 'POST':
       cid = request.form['customerid']
       address = request.form['address']
       telephone = request.form['telephone']
       cursor.execute("""UPDATE customer SET address = ?, telephone = ? WHERE                    customer_id = ?""", (address, telephone, cid))
       g.db.commit()
       return redirect(url_for('customerportal'))
    sql = """SELECT customer.customer_id FROM customer JOIN users ON customer.user_id = users.userid WHERE users.username = (?)"""
    data = list(cursor.execute(sql, (username,)))
    return render_template('edit.html', data=data, username=logged_in_as)

0 个答案:

没有答案