From: | Oliver Elphick <olly(at)lfix(dot)co(dot)uk> |
---|---|
To: | Arindam Haldar <arindamhaldar(at)hotpop(dot)com> |
Cc: | pgsql-interfaces(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org |
Subject: | Re: want basic help with C |
Date: | 2002-05-21 13:31:18 |
Message-ID: | 1021987878.1400.23.camel@linda |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-interfaces |
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(dot)Elphick(at)lfix(dot)co(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Joel Burton | 2002-05-21 13:38:38 | Re: [NOVICE] Problem with inserting: attribute 'extended_reason' |
Previous Message | Marin Dimitrov | 2002-05-21 13:19:57 | Re: Help.. |
From | Date | Subject | |
---|---|---|---|
Next Message | Gaston Micheri | 2002-05-21 21:24:38 | Graphical Tool |
Previous Message | Arindam Haldar | 2002-05-21 12:58:41 | Re: want basic help with C |