Skip to content

Instantly share code, notes, and snippets.

import sqlite3, argparse
def remove_snapshots(fn):
conn = sqlite3.connect(fn)
c = conn.cursor()
c.execute("SELECT id,contents from snapshot ORDER BY id DESC LIMIT 1;")
last_snapshot,last_contents = c.fetchone()
c.execute(f"UPDATE snapshot set parent=NULL;")
c.execute(f"DELETE FROM snapshot WHERE id!={last_snapshot};")
c.execute(f"DELETE FROM file_contents WHERE id!={last_contents};")