pgdb-rs
A small rust crate that allow easy creation and running of temporary Postgres databases, typically used for unit tests or similar things:
let user = "dev";
let pw = "devpw";
let db = "dev";
// Run a postgres instance on port `15432`.
let pg = build
.start
.expect;
// We can now create a regular user and a database.
pg.as_superuser
.create_user
.expect;
pg.as_superuser
.create_database
.expect;
// Now we can run DDL commands, e.g. creating a table.
let client = pg.as_user;
client
.run_sql
.expect;
See the documentation for details.