Add ability to compact the database with VACUUM

This commit is contained in:
Miguel Jacq 2025-11-04 14:55:59 +11:00
parent 27ba33959c
commit 7548f33de4
Signed by: mig5
GPG key ID: 59B3F0C24135C6A9
3 changed files with 69 additions and 16 deletions

View file

@ -464,6 +464,16 @@ class DBManager:
else:
raise ValueError(f"Unsupported extension: {ext}")
def compact(self) -> None:
"""
Runs VACUUM on the db.
"""
try:
cur = self.conn.cursor()
cur.execute(f"VACUUM")
except Exception as e:
print(f"Error: {e}")
def close(self) -> None:
if self.conn is not None:
self.conn.close()