Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import sqlite3
import contextlib
import os
import sys
def clean_binja_snapshots(conn, limit = 1):
with conn as cur:
for section in [ 'snapshot', 'file_data' ]:
cur.execute(f'DELETE FROM {section} WHERE id NOT IN (SELECT id FROM {section} ORDER BY id DESC LIMIT ?)', (limit,))
with conn as cur:
cur.execute('VACUUM')
if __name__ == '__main__':
if len(sys.argv) > 1:
db_file = sys.argv[1]
else:
db_file = input('Enter *.bndn name: ')
if os.path.isfile(db_file):
with contextlib.closing(sqlite3.connect(db_file)) as conn:
conn.set_trace_callback(print)
clean_binja_snapshots(conn, 1)
else:
print('%s does not exist' % db_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.