Thread: What does "pgoptions" should contain in C - function PQsetdb

What does "pgoptions" should contain in C - function PQsetdb

From
Monika Farkasova
Date:
Hello,

I work with postgresql-6.3.2-10 on Linux Redhat 5.2

In simple example of database connection in C-language (in
documentation) you set the pgoptions=NULL. It works.

How cat I say to function
PQsetdb(char * pghost, char * pgport, char *pgoptions, char * pgtty,
     char * dbName);
that I want to connect database  as user=someone and with password=
something.

example:

char *pghost, *pgport, *pgoptions, *pgtty, *dbName;

pghost="hron.fei.tuke.sk";
pgport="5432";
pgoptions="??????????";
pgtty=NULL;
dbName="student"

PQsetdb(pghost,pgport,pgoptions,pgtty,dbName);


What does the "pgoptions" contain and what is the syntax instead of NULL.

In dba.conf I have set the password passwordfile.

I tryed to use the syntax of  PHP function for postgres:
    pg_Connect("dbname=db user=someone password=something");

in C function as:
         PQsetdb("dbname=db user=someone password=something");

but it does not work.

I can not use the PQOPTION in psql, too.

    Monika Farkasova