PostgreSQL vacuum script

PostgreSQL does have a built in auto vacuum , but sometimes you just want a small script that can be ran through Jenkins to perform the vacuum for you. Wanted to share with you guys a small Python script I wrote that will perform a VACUUM VERBOSE ANALYZE on every table within a database. You will need to get psycopg2 installed from PyPi first: pip install psycopg2 At which point you should be able to use the below script with the correct environment variables to vacuum your database: