Start and stop a temporary postgres for testing

Latest on Hackage:

See all snapshots tmp-postgres appears in

BSD-3-Clause licensed by Jonathan Fischoff

Module documentation for

This version can be pinned in stack with:tmp-postgres-,2589

Travis CI Status


tmp-postgres is a library for creating a temporary postgres instance on a random port for testing.

result <- start []
case result of
  Left err -> print err
  Right tempDB -> do
     -- Do stuff
     stop tempDB



$ brew install postgres
$ stack install tmp-postgres


Ubuntu’s PostgreSQL installation does not put initdb on the PATH. We need to add it manually.

$ sudo apt-get install postgresql-VERSION
$ echo "export PATH=$PATH:/usr/lib/postgresql/VERSION/bin/" >> /home/ubuntu/.bashrc
$ stack install tmp-postgres