Skip to content
Quickly spin up a temporary PostgreSQL test databases
Branch: master
Clone or download
eradman Remove License section from the README
gitlab/github provide a link at the top of the page
Latest commit 4bdd020 Jun 13, 2019

Ephemeral PostgreSQL

Run tests on an isolated, temporary PostgreSQL database.

Temporary database created with pg_tmp have a limited shared memory footprint and are automatically garbage-collected after the number of seconds specified by the -w option (the default is 60).

pg_tmp reduces the wait time for a new database to less than one second by initializing a database in the background that is used by subsequent invocations.

Installation - BSD, Mac OS, and Linux

make install

Or to specify a specific installation location

PREFIX=$HOME/local make install

Installation - Mac OS/Homebrew

brew install ephemeralpg

Installation - SmartOS/Solaris

LDFLAGS='-lsocket -lnsl' make install

Man Page Examples

Create a temporary database and run a query:

psql $uri -f my.sql

Start a temporary server with a custom extension:

uri=$(pg_tmp -o "-c shared_preload_libraries=$PWD/auth_hook")
psql $uri -c "SELECT 1"


  • KSH or BASH
  • PostgreSQL 9.3+


A release history as well as features in the upcoming release are covered in the NEWS file.

You can’t perform that action at this time.