0

I am trying to submit a form into DB Browser Sqlite. I've created a table. I am able to store the data into Sqlite. However, once I add in a function to execute a cofirmation popup box in submit button (submitclaim.html), I was displayed with this error

sqlite3.OperationalError: database is locked

When I try to submit a form to the table, it occurs on the line:

    c.execute("INSERT INTO SubmitClaim VALUES (?,?,?,?,?)", (depart, type, uploadre, amt, description)

This is my 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__)
     

This is my 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!");
    }

1 Answer 1

0

You just have to close the Database in DB Browser SQLITE and run the code

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.