Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use SQLite 3's vacuum command in Python

Tags:

I cannot find any example on the net of how the SQLite 3 vacuum command is done on a database.

like image 926
james Avatar asked Jan 17 '11 12:01

james


People also ask

How does SQLite VACUUM work?

The VACUUM command works by copying the contents of the database into a temporary database file and then overwriting the original with the contents of the temporary file. When overwriting the original, a rollback journal or write-ahead log WAL file is used just as it would be for any other database transaction.


1 Answers

Just open a connection and execute the VACUUM command;

conn=sqlite3.connect(SQLITE_FILE) conn.execute("VACUUM") conn.close() 
like image 144
Utku Zihnioglu Avatar answered Nov 03 '22 22:11

Utku Zihnioglu