Database Reference
In-Depth Information
Using PQsetdbLogin
The PQsetdbLogin function is another variant to connect to the PostgreSQL server.
This function has a limited number of parameters and all other parameters previously
discussed are used as default values. The syntax for PQsetdbLogin is as follows:
PGconn *PQsetdbLogin (const char *pghost,
const char *pgport,
const char *pgoptions,
const char *pgtty,
const char *dbName,
const char *login,
const char *pwd);
Whenever you get the following error message while connecting to
PostgreSQL, it means that the PostgreSQL server is not running, at least
not on the 5432 port:
connection to database failed
could not connect to server: No such file or directory
Is the server running locally and accepting connections
on Unix domain socket "/tmp/.s.PGSQL.5432"?
You need to check the host and port on which the PostgreSQL server is
running.
Using PQsetdb
The PQsetdb function is not a function but is macro deined, which calls the
PQsetdbLogin function with the default username and password. The syntax
for PQsetdb is as follows:
PGconn *PQsetdb(char *pghost,
char *pgport,
char *pgoptions,
char *pgtty,
char *dbName);
 
Search WWH ::




Custom Search