Skip to main content

connect_postgres

Function connect_postgres 

Source
pub fn connect_postgres(conn_str: &str) -> Result<Backend>
Expand description

Open a Postgres connection from a full libpq/URI connection string.

The string may embed a password; do not log it. Prefer building it via conn::open, which pulls the secret from the environment. On failure the error is redacted so no secret leaks into logs.

No TLS is built in. To keep the password off the wire in cleartext the connection is refused (fail closed, before any network I/O) unless every host is loopback or a Unix socket, or the string explicitly says sslmode=disable. sslmode=require is refused too, since it cannot be honoured. Reach a remote server over an SSH tunnel or a local proxy.