postgres-tmp-0.1.0.1: Create a temporary database that is deleted after performing some operation

Safe HaskellNone
LanguageHaskell2010

Database.PostgreSQL.Tmp

Description

Create temporary postgresql databases.

The main usecase for this are tests where you don’t want to assume that a certain database exists.

Synopsis

Documentation

withTmpDB :: (DBInfo -> IO a) -> IO a Source #

Convenience wrapper for withTmpDB' using defaultDB

withTmpDB' :: ByteString -> (DBInfo -> IO a) -> IO a Source #

Create a temporary database and a temporary role that the callback can operate on. After the action has finished the database and the role are destroyed.

This function assumes that the connection string points to a database containing the tables called pg_roles and pg_database and that the user has the CREATEDB and CREATEROLE privileges.

newRole :: Connection -> IO Text Source #

Create a new role that does not already exist and return its name.

The new role does not have a password and has the CREATEDB privilege. The database that the connection points to is assumed to contain a table called pg_roles with a rolname column.

newDB :: Connection -> Text -> IO Text Source #

Create a new database that is owned by the user.

defaultDB :: ByteString Source #

Connection string for the postgres database owned by the postgres user

data DBInfo Source #

The data necessary to connect to the temporary database

Constructors

DBInfo 

Fields