# Temp PostgreSQL The `temp-postgres` utility runs the PostgreSQL server off a temporary data directory. See [this][intro] blog post for an introduction. This project's original source code is hosted [here][home]. [intro]: https://www.skreutz.com/posts/temporary-postgresql-server/ [home]: https://git.skreutz.com/temp-postgres.git/ ## Usage Create and serve a temporary database: $ temp-postgres Wrap the `psql` command to connect to the temporary database once the server is ready: $ temp-postgres -- psql Run [SQLx integration tests](https://docs.rs/sqlx/latest/sqlx/attr.test.html) against a temporary database: $ temp-postgres -- cargo test Or configure `temp-postgres` as a wrapper for [cargo-nextest](https://nexte.st/): ```toml experimental = ["wrapper-scripts"] [scripts.wrapper.temp-postgres] command = 'temp-postgres' [[profile.default.scripts]] platform = { host = 'cfg(unix)' } run-wrapper = 'temp-postgres' ``` See the manual page for details. ## Dependencies The `temp-postgres` utility depends on `sh(1)` and `postgres(1)`. On OpenBSD you can install the dependencies using `pkg_add(1)`: $ doas pkg_add postgresql-server postgresql-client On FreeBSD you can install the dependencies using `pkg-install(8)`: $ sudo pkg install postgresql16-server postgresql16-client On Void Linux you can install the dependencies using `xbps-install(1)`: $ sudo xbps-install -S dash postgresql postgresql-client On Arch Linux you can install the dependencies using `pacman(8)`: $ sudo pacman -Syu postgresql ## Installation $ ./configure $ make $ sudo make install Alternatively you can run (or install) the experimental Nix flake. $ nix run git+https://git.skreutz.com/temp-postgres.git -- --help