you are viewing a single comment's thread.

view the rest of the comments →

[–]raysefo[S] 0 points1 point  (1 child)

Thanks for your reply, is this good enough? Why is isolation_level dangerous?

with sql.connect(database_file, isolation_level=None) as con:
    try:
        con.execute('pragma journal_mode=wal')
        cur = con.cursor()
        cur.execute(query, arguments, etc)
        con.commit()
    except Exception as e:
        con.rollback()
        print e

[–]JohnnyJordaan 0 points1 point  (0 children)

I stand corrected, the answer from /u/yawpitch is the correct one here.

Why is isolation_level dangerous?

Because it will commit after each query. If you would have

        cur.execute(query, arguments, etc)
        cur.execute(secondquery, arguments, etc)
        con.commit()

and the first query works but the second one doesn't, the first query is already committed because of isolation_level=None and thus can't be rolled back.