Reputation: 14573
I'm looking for options for abstracting database server details away from my application (in c++), I'd like to write my code to be independent of the actual database backend. I know MySQL has a nice library, but I don't want to be tied to a single database implementation. Are there good options for this?
Upvotes: 5
Views: 7728
Reputation: 10819
My opinion is to forget about a cross-database driver, and focus on finding or creating a cross-database Data Access Layer. A few reaons:
LIMIT
and OFFSET
for example, commonly used for paging, isn't universal.So, go ahead and use libmysql
by itself - just hide it behind a compiler firewall in your DAL, and be prepared to swap it out later. You can protect yourself from shifting infrastructure without having to use a lowest-common-denominator SQL wrapper.
If that doesn't jive with you, check out SQLAPI++.
Upvotes: 3
Reputation: 9140
libodbc++ provides a pretty good API. Also the big guys Qt (see Kyle Lutz' answer) & wxWidgets have db abstraction layers, so it may be a good idea to use them if you plan to use/you're already using any other parts of those frameworks.
Upvotes: 1
Reputation: 18339
SOCI is good. Supports multiple databases, works well, modern C++ style API, works with boost.
Upvotes: 4
Reputation: 8036
Qt provides a database abstraction layer. See: http://doc.trolltech.com/4.6/qsqldatabase.html.
Upvotes: 1