On Tue, 2002-05-21 at 13:34, Arindam Haldar wrote:
> Arindam Haldar wrote:
> hi,
> i went thru the docs on programming interface of postgresql with c. But
This is the libpq interface, yes?
You need to read the libpq reference: chapter 1 of the Programmer's
Guide.
> am unable to understnad to use the interface to query a select
> statement. the database is--->masterdb & in it there is a table
> -->colleges with a few columns & a few records for testing..
> now i want to use a general select statement--> select * from colleges,
> but going thru the docs again & again from different sites am unable to
> undestand how to use it.
> can u gove me a basics to use the funstion to use the same & print the
> rows in the tables
First you have to connect to the database, using PQconnectdb() or a
related function. This returns a handle which you have to use in all
other API calls for this connection.
Send your command or query to the backend with PQExec()
This returns a query handle which you can use to get the results with
the various calls listed in section 1.3.4 of the Programmer's Guide.
Close the connection with PQfinish()
> pls--> i wanted to ask this 2nd Question-->is it necessary to start
> postgreswith option -i too to accept connection from localhost(C
> programme). command line works fine without the said option but unless i
> use -i , i cannot connect to postgres.
If you connect through TCP/IP you always need the -i option on the
postmaster. Connecting with host set to localhost is a TCP/IP
connection. Connecting with host set to nothing connects through a Unix
socket on the local machine; this does not need the -i option.
--
Oliver Elphick Oliver.Elphick@lfix.co.uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
"O come, let us worship and bow down; let us kneel
before the LORD our maker." Psalms 95:6