Updated on 2025-02-27 GMT+08:00

PQconnectdb

Description

Establishes a new connection with the database server.

Prototype

PGconn *PQconnectdb(const char *conninfo);

Parameter

Table 1 PQconnectdb parameter

Keyword

Description

conninfo

Connection string. For details about the fields in the string, see Connection Parameters.

Return Value

PGconn * points to the object pointer that contains a connection. The memory is applied for by the function internally.

Precautions

  • This function opens a new connection with the parameters specified by conninfo.
  • The input parameter can be empty, indicating that all default parameters can be used. It can also contain one or more parameters separated by spaces or it can contain a URL.

Example

For details, see Typical Application Development Examples.