Midwess

Single-process options

use pglite::{LocaleProvider, PGlite, PGliteOptions};

let db = PGlite::open_with(
    "./data",
    PGliteOptions {
        username: "app".into(),
        database: "app".into(),
        relaxed_durability: false,
        start_params: vec!["shared_buffers=16MB".into()],
        locale_provider: LocaleProvider::Libc
    }
).await?;
Field Default Purpose
username postgres Session user and initdb owner.
database postgres Database name.
relaxed_durability false Disables fsync in engine startup.
start_params [] Extra Postgres -c parameters.
locale_provider Libc Libc or Icu.

Temporary database

let db = PGlite::open_temp_with(PGliteOptions::default()).await?;

Temporary directories are removed when the database handle is dropped.

Multi-process settings

Use MultiProcessOptions when enabling the multiple-process feature. It includes connection pool sizing and extra postmaster slots for external clients.

Durability tradeoff

relaxed_durability: true is useful for tests and throwaway workloads. It is not a replacement for PostgreSQL durability in production data directories.