I cannot find any example on the net of how the SQLite 3 vacuum command is done on a database.
the other solutions didn't work for me Error was "can't vacuum with transaction" or similar
here what worked for me:
import sqlite3 conn = sqlite3.connect('my_test.db', isolation_level=None) conn.execute("VACUUM") conn.close()