0

in my flask app I have the following code :

def get_db():
    conn =sqlite3.connect(db_path)
    cur =conn.cursor()
    cur.execute("""CREATE TABLE IF NOT EXISTS Files (name TEXT, 
    year TEXT, subject TEXT, kind TEXT, correction INT, 
    description TEXT, date TEXT)""")
    return cur

def query_db(query, args=(), one=False):
    print args   
    cur = get_db().execute(query, args)
    rv = cur.fetchall()
    cur.close()
    return (rv[0] if rv else None) if one else rv

@app.route('/admin/<year>/<matiere>/<fichier>')
@requires_auth
def delete(year, matiere, fichier):
    query_db("DELETE from Files where name=?",[fichier])
    return 'Deleted'

But when I use this code, the data isn’t deleted, and I don’t understand why. Has someone an idea ?

0

1 Answer 1

1

I think you are missing commit conn.commit()

def query_db(query, args=(), one=False):
    print args   
    cur = get_db().execute(query, args)
    rv = cur.fetchall()
    conn.commit()
    cur.close()
    return (rv[0] if rv else None) if one else rv
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.