views:

403

answers:

6
+1  Q: 

C++ SQL Interface

Has anybody produced a C++ wrapper for SQL that allows to interface to flat files or an active DB server or possable an in memory DB depending on run-time configuration.

I have seen:

  • SQLite
  • mySQL

I am sure there are others.

Both of these are really C and though they provide the same functionality there is no common interface (that I have found).

Anybody have suggestions.

A: 

You should write your own, abstract, C++ interface over these libraries so that you can migrate between them at run time. That would be the best solution to this. Remember that just because it doesn't use objects does not mean that it is not C++. You can use their code just fine in C++ with your own wrapper. It would be the most effective solution.

nlaq
+1  A: 

SQLite has a quite a few C++ wrappers. You can also load tables completely into memory by setting the appropriate cache settings in the SQLite database.

As far as abstractions go, ODBC is definitely the most popular language and DB independent API. For a C++ specific solution, there is the commercial SQLAPI++, which I've never used. Other libraries I know of are:

  • Debea, which works under Linux and Windows
  • LiteSQL, which is *nix only
codelogic
A: 

I was looking for answer to this same question a few years ago. I went through a bunch of sollutions.

Very, very easy, simple and pleasant solution to work with a different databases from using C++ is provided by 3rd party OTL4 library. I was using it for a year or more before I moved to C# and I was very happy.

Greets Mariusz

Project Webpage: http://otl.sourceforge.net

Some comments on OTL: http://otl.sourceforge.net/otl3_comm.htm

aristo
+1  A: 

I suggest MySQL++.You can write code c++ style.It's able carete template query

User manual of MySQL++

Chatsiri.rat
A: 

How about SOCI? It provides a common API for SQL databases, but not plain text files.

A: 

MySQL Connector/C++ is a C++ implementation of JDBC 4.0

The reference customers who use MySQL Connector/C++ are: - OpenOffice - MySQL Workbench

Learn more: http://forums.mysql.com/read.php?167,221298