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:
$ pg list
List databases (same as psql -l), or with –short, prints only their names.
$ pg drop db_name
Drops a database. The only difference between this and
dropdb is that it always uses
Or more interesting things:
$ pg mv origin target
Rename a database after killing all connections to
$ pg copy origin target
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
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.