Skip site navigation (1) Skip section navigation (2)

Getting to learn libpqxx

From: Michiel Lange <michiel(at)minas(dot)demon(dot)nl>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Getting to learn libpqxx
Date: 2003-04-09 22:30:40
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-interfaces
Hello everybody again,

I went out to investigate and try if I could master libpqxx, for libpq++ 
works not at all. Seeing it is discontinued, and people are encouraged to 
use libpqxx, I was so bold as to try that ;-)

Only to discover that there is hardly any documentation on how to access 
stuff... now I, myself am more a C-programmer, and I know C++ is pretty 
much different... it is really hard for me to think in classes and stuff, 
to think object-oriented...

So, now you know I am an earthling :P

I tried this kind of approach, the idea was to start out simple... so don't 
laugh at the attempt ...

#include <pqxx/connection.h>

int main(int argc, char *argv[])
	Connection *db;
	char uname[250]; // username
	char passwd[250]; // password
	char host[250]; //hostname
	char passwd[250]; //password
	char dbase[250]; //database name
	char connstring[1264];
	... some output and input to get values for all these char arrays...

	connstring = "host=" >> host >> "database=" >> dbase >> "username=" >> 
uname >> "password=" >> passwd;
	db = new Connection(connstring,true);

		cout << "Connection succesful!" << endl;
		cout << db->Options();
		cout << "Something went wrong... oops" << endl;
	delete db;
	return 0;

I get my first errors at "Connection *db" declaration... there is no 
Connection defined...
Can anyone point out how to reference the classes libpqxx has?

Also I was curious if my connstring was correctly built, but that is 
another subject I think... One other very important thing would be: how can 
I find out the error PostgreSQL will throw at me when I did something ugly? 
At least I can find out the problem, when I make one then...



pgsql-interfaces by date

Next:From: Tom LaneDate: 2003-04-09 22:30:51
Subject: More thoughts about FE/BE protocol
Previous:From: C. MajDate: 2003-04-09 16:42:53
Subject: Re: problem to connect

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group