Helper that gives
psql
PostgreSQL shell on the default database (ourbigbook
).To select another database use the
-d
option: E.g. to use the ourbigbook_test
database from OurBigBook Web run unit tests in PostgreSQL:bin/psql -d ourbigbook_test
psql
just forwards everything to the underlying psql
command, so you can e.g. run a SQL script stored in a file with:bin/psql <tmp.sql
bin/psql -c 'select * from "Id"'
web/bin/psql
#!/usr/bin/env bash
db=ourbigbook
args=()
while [ $# -gt 0 ]; do
case "$1" in
-d)
db="$2"
shift 2
;;
*)
args+=("$1")
shift
;;
esac
done
PGPASSWORD=a psql -U ourbigbook_user -h localhost "$db" "${args[@]}"