Postgres command line
I find the postgres command line tools slightly annoying to use, so I wrote pg.
With it, I can run commands in a more natural way. For instance:
List databases (same as psql -l), or with –short, prints only their names.
Drops a database. The only difference between this and dropdb
is that it always uses --if-exists
.
Or more interesting things:
Rename a database after killing all connections to origin
.
Creates a “copy” of a database after killing all connections to origin
. I use this to create fast snapshots that I can go back to later, much like version control.
These are very simple wrappers around createdb
, psql
etc, but since I was starting to repeat myself a lot, I decided it was worth it.
You can find the code on github, along with tests, yes.
Comments