pg-setup
Simple helper to create and drop Postgres databases. Useful for tests.
This uses either the psql command line utility (default) or the sqlx and sqlx-cli (which makes use of sqlx migrations).
Use the sqlx feature for that.
Example:
#
let db_uri = "postgres://localhost:5432/pg_setup_example";
let db = new
.schema
// optionally keep db
.keep_db
.start
.await?;
// optionally create a table
db.create_table
.await?;
// execute sql
db.execute.await?;
// db will be dropped at the end of the scope, unless `keep_db` is called!
In case you want to keep the db around for debugging you can call [PostgresDB::keep_db].
Will use the public schema by default but you can set this with [PostgresDB::schema].
!
License: MIT