[Libpqxx-general] Is it better to keep the connection or to open, use and close it?
Jeroen Vermeulen
jtv at xs4all.nl
Tue Aug 18 15:30:42 UTC 2009
Matheus Araújo Aguiar wrote:
> I'm using libpqxx through a c++ class i've coded called db_interface.
> This class abstracts several queries i have to make in my program. Right
> now i'm wondering what would be the best way of handling the connection
> with the database. So would it be better to open the connection once,
> and use it through the lifetime of the object or just open the
> connection, make the requested transactions and close it ?
Keep it open. If your connection dies between transactions, the library
will reconnect transparently.
Jeroen
More information about the Libpqxx-general
mailing list