Hi all,
I've just started to learn postgres database and am trying to get it
working with libpqxx. I wrote a simple test file below (at the end of
this message)
When running the executable as any user other than postgres, I got an exception:
[EMAIL PROTECTED] libpqxx]$ ./pqxxtest
dbname = test
username = test
port = 5432
connection is open? 0
Runtime error: FATAL: user "test" does not exist
I already created an user 'test' and granted all priviledge. By doing
"select * from pg_users;" from pgsql command line, I could see 2 users
in the table, 'test' and 'postgres'. Why did I still get the exception
"user does not exist"?
Now, if I logged in as postgres, then connection is established, but I
can't execute the "select * from test_tbl;"; it complains about not
seeing table test_tbl even though I already created one via command
line.
[EMAIL PROTECTED]:/home/van/libpqxx$ ./pqxxtest
dbname = test
username = postgres
port = 5432
connection is open? 1
Runtime error: ERROR: relation "test_tbl" does not exist
If in the test program itself, I call w.exec("CREATE TABLE
test_tbl....") and insert some data in, then the select call returns
the correct result. But via command line, I can't see newly created
test_tbl at all. Could anybody help me with this?
I'm using Debian 3.1, postgreSQL 8.1 and libpqxx2.5.5
Thanks a lot!
Van
#include <stdlib.h>
#include <iostream>
#include <pqxx/pqxx>
using namespace std;
using namespace pqxx;
int main( int argc, const char* argv[] )
{
try
{
connection conn("dbname=test");
cout << "dbname = " << conn.dbname() << endl;
cout << "username = " << conn.username() << endl;
cout << "port = " << conn.port() << endl;
cout << "connection is open? " << conn.is_open() << endl;
conn.activate();
//result res = w.exec( "select * from test_tbl;" );
//cout << "Found " << res.size() << " entries:" << endl;
//for ( result::const_iterator r = res.begin();
// r != res.end();
// ++r )
//{
// cout << r[0].c_str() << endl;
//}
}
catch ( const runtime_error& e )
{
cerr << "Runtime error: " << e.what();
exit ( EXIT_FAILURE );
}
catch ( const exception& e )
{
cerr << "Exception caught: " << e.what();
exit ( EXIT_FAILURE );
}
catch (...)
{
cerr << "Unknown exception caught" << endl;
exit( EXIT_FAILURE );
}
exit( EXIT_SUCCESS );
}
_______________________________________________
Libpqxx-general mailing list
[email protected]
http://gborg.postgresql.org/mailman/listinfo/libpqxx-general