One Unified Global Perspective
Communications with a Global Perspective
Home
Intro
Contact Us
Voice over IP
PBX Solutions
Services
Support
Glossary
Open Source
Blog
Forum

WebMail





2007 Oct 05 - Fri

libpqxx: A PosgreSQL C++ Wrapper Library

I've looked at the C library for PostgreSQL and then wanted to see if there were any C++ wrappers for it. The most current appears to be libpqxx. On first blush, it looks very good. It if functional and robust. But... it has one draw back. The library insists on converting all binary stuff into text for passing back to the caller. For some applications, that can be a reasonable library simplifier.

But in this day and age of Templates and polymorphism, it seems to be a copout. Yes, if I had time, I'd probably try my hand at implementing some sort of 'variant' implementation to handle the various types of data that come back.

Sigh. As much as I'd like to use the library, I really want my data in the native form in which I stored it. Perhaps once I've worked with the API, and I've worked my own working version of variants, maybe I'll be in a position to offer up some workable suggestions.

... several hours later ...

I now realize that the PostgreSQL API returns everything as strings. So now I understand the reasoning behind the library and what it returns.

To get binary values, from my understanding, one has to use the COPY routines and decipher the result streams directly. I would have hoped there was some middle ground, where the API will provide the binary values when needed. The API implies that it does, but in actual fact, didn't. I spent an hour or two figuring it out the hardway. I'm really going to have to figure out how gdb works so I can single step through stuff and analyze variables. As it was, I reverted back to the stone age and put in print statements to figure out what was happening.

Now I have a tri-choice:

  • Stick with the C API, which seems to have everything one needs, including access to true parameterized queries (I found out after the fact, that the Perl libraries actually do string concatenation, which creates a possibility for SQL Injection attacks).
  • Use the libpqxx library and convert stuff to binary when I need it. I must say working with everything as strings is a simplifying assumption, but doesn't do much for accuraccy and performance.
  • Start working on some sort of wrapper to examine the results of COPY commands, which is probably more work than I really want to do right now.



Blog Content ©2008
Ray Burkholder
All Rights Reserved
ray@oneunified.net
(441) 505 7293
Available for Contract Work
Resume

RSS: Click to see the XML version of this web page.

View Ray 
Burkholder's profile on LinkedIn
technorati
Add to Technorati Favorites



October
Su Mo Tu We Th Fr Sa
  5
     


Main Links:
Monitoring Server
SSH Tools
QuantDeveloper Code

Special Links:
Frink

Blog Links:
Sergey Solyanik
Marc Andreessen
HotGigs
Micro Persuasion
... Reasonable ...
Chris Donnan
BeyondVC
lifehacker
Trader Mike
Ticker Sense
HeadRush
TraderFeed
Stock Bandit
The Daily WTF
Guy Kawaski
J. Brant Arseneau
Steve Pavlina
Matt Cutts
Kevin Scaldeferri
Joel On Software
Quant Recruiter
Blosxom User Group
Wesner Moise
Julian Dunn
Steve Yegge

2007
Months
Oct




Mason HQ

Disclaimer: This site may include market analysis. All ideas, opinions, and/or forecasts, expressed or implied herein, are for informational purposes only and should not be construed as a recommendation to invest, trade, and/or speculate in the markets. Any investments, trades, and/or speculations made in light of the ideas, opinions, and/or forecasts, expressed or implied herein, are committed at your own risk, financial or otherwise.