Postgres module

parse_conninfo

procedure · 1 overloadsince 0.27.0Source

libpq's connection strings: a URI (see parse_url) or host=localhost port=5432 dbname=app, where a value with spaces is quoted, 'a value', and \ escapes the next character (\' and \\ inside quotes). Parameters (keywords): host, hostaddr, port, user, password, passfile, dbname, sslmode, sslnegotiation (direct), sslrootcert (a PEM file, or system), sslcert, sslkey, sslpassword, sslcertmode, sslcrl, sslcrldir, sslsni, sslkeylogfile, ssl_min_protocol_version, ssl_max_protocol_version, channel_binding, application_name, fallback_application_name, options, connect_timeout (seconds), client_encoding, replication and require_auth. libpq's other keywords are accepted and ignored. Errors read like libpq's.

With use_environment the keywords that were not given come from PGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASE and the other variables libpq reads; otherwise only the text counts. The config owns its strings: free_config.

parse_conninfo :: (
    text: string,
    use_environment := false
) -> (Config, Pg_Error)

libpq's connection strings: a URI (see parse_url) or host=localhost port=5432 dbname=app, where a value with spaces is quoted, 'a value', and \ escapes the next character (\' and \\ inside quotes). Parameters (keywords): host, hostaddr, port, user, password, passfile, dbname, sslmode, sslnegotiation (direct), sslrootcert (a PEM file, or system), sslcert, sslkey, sslpassword, sslcertmode, sslcrl, sslcrldir, sslsni, sslkeylogfile, ssl_min_protocol_version, ssl_max_protocol_version, channel_binding, application_name, fallback_application_name, options, connect_timeout (seconds), client_encoding, replication and require_auth. libpq's other keywords are accepted and ignored. Errors read like libpq's.

With use_environment the keywords that were not given come from PGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASE and the other variables libpq reads; otherwise only the text counts. The config owns its strings: free_config.

Parameters

text: string
a URI or a key=value list.
use_environment := false
fill the keywords left unset from the PG* environment variables.

Returns

See also