Constructor

PgsqlConnectionnew

Declaration

DexFuture*
pgsql_connection_new (
  const char* const* keywords,
  const char* const* values,
  int expand_dbname
)

Description

Creates a new connection to a PostgreSQL database server.

This function initiates an asynchronous connection to a PostgreSQL server using the provided connection parameters. The keywords and values arrays must be parallel arrays containing connection parameters such as “host”, “port”, “dbname”, “user”, “password”, etc.

The function returns a DexFuture that resolves to a PgsqlConnection when the connection is successfully established, or rejects with an error if the connection fails.

If expand_dbname is non-zero, the database name will be expanded using the same rules as libpq’s connection string expansion.

Parameters

keywords

Type: An array of char*

Array of connection parameter keywords.

The array must be NULL-terminated.
The data is owned by the caller of the function.
Each element is a NUL terminated UTF-8 string.
values

Type: An array of char*

Array of connection parameter values.

The array must be NULL-terminated.
The data is owned by the caller of the function.
Each element is a NUL terminated UTF-8 string.
expand_dbname

Type: int

Whether to expand the database name.

Return value

Type: DexFuture

A DexFuture that resolves to a PgsqlConnection or rejects with error.

The caller of the function takes ownership of the data, and is responsible for freeing it.