Thread: Postgres and C/C++

Postgres and C/C++

From
"Brian C. Doyle"
Date:
Hello all,

Where would I find examples of some C files that connect to a postgresql
db  I am just starting out with c and know Postgresql rather well and have
done a lot of development with  PHP.

So I need to know what else do I need to write a C program that will
connect to a database in Postgresql and thus interact with that database.

The interface I am trying to create is in windows with Postgresql in linux.


Re: Postgres and C/C++

From
Doug McNaught
Date:
"Brian C. Doyle" <bcdoyle@mindspring.com> writes:

> Where would I find examples of some C files that connect to a
> postgresql db I am just starting out with c and know Postgresql
> rather well and have done a lot of development with PHP.
>
> The interface I am trying to create is in windows with Postgresql in linux.

Then you'll probably need to install the PG ODBC driver and learn the
ODBC interface.  The nice thing about that is that it works with
pretty much any database, so you can switch to Sybase or Oracle or
whatever quite easily (not that you'd want to, of course ;)

There should be plenty of ODBC programming info on the web.

-Doug
--
The rain man gave me two cures; he said jump right in,
The first was Texas medicine--the second was just railroad gin,
And like a fool I mixed them, and it strangled up my mind,
Now people just get uglier, and I got no sense of time...          --Dylan

Re: Postgres and C/C++

From
missive@frontiernet.net (Lee Harr)
Date:
On Sun, 8 Jul 2001 17:39:09 +0000 (UTC), Brian Doyle <bcdoyle@mindspring.com>:
> Hello all,
>
> Where would I find examples of some C files that connect to a postgresql
> db  I am just starting out with c and know Postgresql rather well and have
> done a lot of development with  PHP.
>
> So I need to know what else do I need to write a C program that will
> connect to a database in Postgresql and thus interact with that database.
>
> The interface I am trying to create is in windows with Postgresql in linux.


Have you looked at chapters 52,53, and 54 in the documentation?

Section IV, Interfaces, in the docs talks about ecpg and libpq
and using them from C and C++

There is also information there about ODBC and use from Microsoft
windows

There are examples provided.