Hi Andreas,

Andreas Ntaflos wrote:
> Now of course this depends on what the application being written needs 
> to do. Mine is basically a server that reads some configuration 
> information from an XML file on startup and based on that has to a) 
> create a database if it doesn't exist yet and b) fill the database with 
> the data that was extracted from the XML file if the database is still 
> empty. During operation information is read from the database, changed 
> and written back to it, on an event-driven basis, i.e. asynchronous. 
> (The XML parser works and returns a string containing lots of INSERT 
> statements, so that's not the concern.)
> 
> I don't think that is an uncommon or difficult to implement scenario?

Nope, no problem. :-)

> What I'd like to know is what is considered a clean and elegant way of 
> implementing such handling of the database? Would I best write some 
> class or module that provides methods for initializing (connection, 
> transactions) reading from and writing to the database? Or is such 
> wrapping unnecessary because libpqxx is already on a high enough 
> abstraction level so I would be ``abstracting the already abstracted''? 
> Things like that.

libpqxx provides classes that abstract connections, transactions, result 
sets and a number of other things. There's absolutely no need to 
abstract that further.

If I were you, I'd get to know libpqxx a bit first by trying writing 
some simple code (connect to the database, start a transasction, execute 
a query or two, get the results out) and then continue. And the packaged 
tutorial, which takes the shape of a 90-odd example programs that 
exercise every feature of the library (and that are, therefore, also the 
test suite) is actually a very good way of learning how you do things 
like that. It's really very simple -- start at test000.cxx and continue 
until you've seen everything you need to write your program!

Cheers,
Bart
_______________________________________________
Libpqxx-general mailing list
[email protected]
http://gborg.postgresql.org/mailman/listinfo/libpqxx-general

Reply via email to