Updated on 2024-06-03 GMT+08:00

PQsetdbLogin

Description

Establishes a new connection with the database server.

Prototype

PGconn* PQsetdbLogin(const char* pghost, const char* pgport, const char* pgoptions, const char* pgtty,
    const char* dbName, const char* login, const char* pwd);

Parameters

Table 1 PQsetdbLogin parameters

Keyword

Description

pghost

Name of the host to be connected. For details, see the host column described in Connection Parameters.

pgport

Port number of the host server. For details, see the port field described in Connection Parameters.

pgoptions

Command-line options to be sent to the server during running. For details, see the options field described in Connection Parameters.

pgtty

Ignored. (Previously, this option declares the output direction of server logs.)

dbName

Name of the database to be connected. For details, see the dbname field described in Connection Parameters.

login

Username for connection. For details, see the user column described in Connection Parameters.

pwd

Password used for authentication during connection. For details, see the password field described in Connection Parameters.

Return Value

PGconn * points to the object that contains the connection. The memory is allocated inside the function.

Precautions

  • This function is the predecessor of PQconnectdb with a fixed set of parameters. When an undefined parameter is called, its default value is used. The default value can be NULL or an empty string.
  • If the dbName value contains an equal sign (=) or a valid prefix in the connection URL, it is taken as a conninfo string and passed to PQconnectdb, and the other parameters are consistent with those of PQconnectdbParams.