postgres-mktempdb

make temp postgres database


Keywords
postgres, temp, cli
License
Unlicense
Install
pip install postgres-mktempdb==2020.12.3

Documentation

Installation

$ [sudo] pip install postgres-mktempdb
$ [sudo] npm i -g postgres-mktempdb

Examples

$ mktempdb
tmp_LH8LqXy8UGlfMR8zfB3todrc4mwC9Sns

delete temp databases:

$ psql -At -c "SELECT datname FROM pg_database WHERE datname LIKE 'tmp_%'" | xargs -L 1 dropdb

delete temp databases created more than 5 minutes ago:

$ psql -At -c "SELECT datname FROM pg_database
WHERE datname LIKE 'tmp_%' AND (pg_stat_file('base/'||oid||'/PG_VERSION')).modification<now()+interval '5 minutes'" | xargs -L 1 dropdb

readme42.com