This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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};") |