Crate pgtemp

source ·
Expand description

pgtemp is a Rust library and cli tool that allows you to easily create temporary PostgreSQL servers for testing without using Docker.

The pgtemp Rust library allows you to spawn a PostgreSQL server in a temporary directory and get back a full connection URI with the host, port, username, and password.

The pgtemp cli tool allows you to even more simply make temporary connections, and works with any language: Run pgtemp and then use its connection URI when connecting to the database in your tests. pgtemp will then spawn a new postgresql process for each connection it receives and transparently proxy everything over that connection to the temporary database. Note that this means when you make multiple connections in a single test, changes made in one connection will not be visible in the other connections, unless you are using pgtemp’s --single mode.

Structs§

  • A struct representing a handle to a local PostgreSQL server that is currently running. Upon drop or calling shutdown, the server is shut down and the directory its data is stored in is deleted. See builder struct PgTempDBBuilder for options and settings.
  • Builder struct for PgTempDB.
  • A daemon that listens on the given port and creates a new PgTempDB for each connection it receives, proxying all data to the database. If single_mode is activated, all connections are proxied to the same database.