postgleam/config

Types

Connection configuration for PostgreSQL

pub type Config {
  Config(
    host: String,
    port: Int,
    database: String,
    username: String,
    password: String,
    timeout: Int,
    connect_timeout: Int,
    extra_parameters: List(#(String, String)),
    ssl: SslMode,
    pgbouncer: Bool,
    idle_interval: Int,
    queue_timeout: Int,
  )
}

Constructors

  • Config(
      host: String,
      port: Int,
      database: String,
      username: String,
      password: String,
      timeout: Int,
      connect_timeout: Int,
      extra_parameters: List(#(String, String)),
      ssl: SslMode,
      pgbouncer: Bool,
      idle_interval: Int,
      queue_timeout: Int,
    )

SSL connection mode

pub type SslMode {
  SslDisabled
  SslVerified
  SslUnverified
}

Constructors

  • SslDisabled

    No SSL (plain TCP)

  • SslVerified

    SSL required, verify server certificate (uses system CA store + SNI)

  • SslUnverified

    SSL required, skip certificate verification (for Neon, self-signed certs)

Values

pub fn connect_timeout(config: Config, ms: Int) -> Config

Set connect timeout in milliseconds.

pub fn database(config: Config, database: String) -> Config
pub fn default() -> Config

Create a default config for localhost

pub fn extra_parameters(
  config: Config,
  params: List(#(String, String)),
) -> Config

Set extra startup parameters sent to PostgreSQL.

pub fn host(config: Config, host: String) -> Config
pub fn idle_interval(config: Config, ms: Int) -> Config

Set the health check interval in milliseconds (pool only). Idle connections are pinged at this interval. Default: 1000ms.

pub fn password(config: Config, password: String) -> Config
pub fn pgbouncer(config: Config, enabled: Bool) -> Config

Enable PgBouncer compatibility mode. Uses unnamed prepared statements with Flush to avoid mid-query backend reassignment in PgBouncer transaction pooling mode.

pub fn port(config: Config, port: Int) -> Config
pub fn queue_timeout(config: Config, ms: Int) -> Config

Set the maximum time in milliseconds to wait for a pool connection. If no connection becomes available within this time, returns TimeoutError. Default: 5000ms.

pub fn ssl(config: Config, mode: SslMode) -> Config
pub fn timeout(config: Config, timeout: Int) -> Config
pub fn username(config: Config, username: String) -> Config
Search Document