software/postgres

Start a quick local docker database:

docker run -p 5432:5432 postgres:latest

Connect (from outside):

psql -h localhost -w postgres

Dump current schema with something like:

docker exec 6a018d9d8ef0 pg_dump -U postgres postgres -s | rg -v ^- > schema.sql

Basic status from the psql command line:

\l+     (list databases)
\dt+    (describe table)

Temporary Databases in Tests

Try pg_tmp, though it may not work with high concurrency (due to internal postgres locking), and might need special configuration in CI environments.

Debian also ships with pg_virtualenv for temporary databases.


More refs/links:

  • https://stackoverflow.com/questions/9604723/alternate-output-format-for-psql
  • https://brandur.org/postgres-connections
  • https://www.citusdata.com/blog/2017/07/16/customizing-my-postgres-shell-using-psqlrc/
  • bind "^R" em-inc-search-prev
  • https://www.citusdata.com/blog/2019/07/17/postgres-tips-for-average-and-power-user/
  • https://github.com/citusdata/pg_auto_failover
  • https://repmgr.org/