help on using C for postgresql

From: Madhurima Das <madhurima(dot)das(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: help on using C for postgresql
Date: 2014-02-03 18:31:28
Message-ID: CAMsahj2aogCE33DkAcOyBvp-e4zCvYFJerSCRUDEGU1kAN13uw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am a beginner in Postgresql and trying to write a C++ program to connect
a database and retrieve information from a database.

I have downloaded Postgresql 9.3 in my MAC laptop and could create a
database XXX with a user YYY and password ZZZ. I can create, modify etc
using the pgAdmin3 tool.

Next, I tried connecting the database using the code:

#include <iostream>
#include <pqxx/pqxx>

using namespace std;
using namespace pqxx;

int main(int argc, char* argv[])
{
try{
connection C("dbname=XXX user=YYY password=ZZZ \
hostaddr=127.0.0.1 port=5432");
if (C.is_open()) {
cout << "Opened database successfully: " << C.dbname() << endl;
} else {
cout << "Can't open database" << endl;
return 1;
}
C.disconnect ();
}catch (const std::exception &e){
cerr << e.what() << std::endl;
return 1;
}
}

However, the output says: error: pqxx/pqxx: No such file or directory

When I try to install pqxx, I get configure error as:
PostgreSQL configuration script pg_config not found. Make sure this is in
your
command path before configuring. Without it, the configure script has no
way to
find the right location for the libpq library and its headers.

I would appreciate your help in solving my problem.

Thanks for your patience!!

Regards
Madhurima

Browse pgsql-general by date

  From Date Subject
Next Message Susan Cassidy 2014-02-03 18:53:01 way to custom sort column by fixed strings, then by field's content
Previous Message Tom Lane 2014-02-03 18:09:21 Re: Drop all overloads of a function without knowing parameter types