We help IT Professionals succeed at work.

libpqxx (C++ wrapper for the libpq C API for postgreSQL): calling a function that returns a password, and a function that changes the password.

sternocera
sternocera asked
on
1,587 Views
Last Modified: 2013-11-05
Hello,

I am working on a libpqxx project within visual studio. Having connected to a database, is there some function or method I can call that will :

A. Return the current database password?

B. Change the database password?

If anyone could send me in the right direction with this, it would certainly be appreciated,
Thanks
Sternocera
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2012
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
I'm using libpqxx, a C++ wrapper for libpq. I'm unsure of how to make libpq function calls using a libpqxx connection. I havn't included libpq headers in my project, and I have no idea how libpqxx interfaces with libpq. Could you offer any suggestions as to how I could call libpq functions like this?

Thanks,
Sternocera
jkr
CERTIFIED EXPERT
Top Expert 2012

Commented:
Yes, that's clear. But since it is only a wrapper, you should be able to use the underlying functionality also. Why not giving it a short try and see if the compiler accepts a call to 'PQpass()'?
basic_connection returns a reference to options. You should get the P/W from that, I guess.

Author

Commented:
From the libpq features faq:

"For my program I need to access some C-level libpq structure that libpqxx hides from me. Can you add a member function that lets me do this?

Generally, no. If you require support for specific high-level functionality, the better solution is usually to build it into the abstraction layer rather than to break the abstraction layer open like this.

Also, the isolation that the abstraction layer provides allows libpqxx to do things like automatic connection recovery. Such things can be impossible if the library does not have full and unique control over the underlying C-level structures, or in other cases they might lead to subtle and complex bugs in your program. "

I'll have to look for another way...
Thanks
Did you have no joy reading options from the connection object? I've not checked, but it should be a simple string for parsing. It is the same string that will have been passed to the connection object when its was constructed.

 const string& options = your_connection.options();
 cout << options << '\n';
 

Author

Commented:
I can always store the password in some variable so that it can be compared to another password entered by the user at a later stage - this isn't a problem. The problem is, how can I change the password?
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Commented:
Hi sternocera,
Wondering if you can help me get my hands on the .h, .lib and .dll for VS2010?  Some points for you here if you can help!  https://www.experts-exchange.com/Database/PostgreSQL/Q_27410988.html

Thanks,
Mike
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.