What are the alternatives for a library with multiple databases for C / C ++?

I want to write an application that should be able to connect to several databases (this will be configured by the parameters at startup). The application will have different queries for each database engine, this is not a problem.

The problem is that I want to be able to connect to various database engines. Java has JDBC, Perl has DBI. What is C ++?

The more I don’t want to use database drivers with too strict licenses (commercial). GPL may be, but I would like to avoid it.

+7
source share
4 answers

Almost every existing DBMS engine provides an ODBC interface. I think JDBC is actually an ODBC clone.

So you want to use the C ++ wrapper for the ODBC API, which implements RAII to ensure that database resources will be released in case of an exception, etc. For example: http://simpledb.sourceforge.net/

+1
source

Older OLE connections exist. Using OLE, you can connect to the Flat File, Oracle, SQL, or MySql database as long as you have the correct drivers installed.

0
source

ODBC is the most compatible and the lowest level. OLE DB is a higher level and easier to work with, so if you find an OLE DB provider for all possible database systems, this is the way to go. Otherwise, ODBC is your option, since almost all database systems support it.

EDIT: Check out this link: http://blogs.msdn.com/b/sqlnativeclient/archive/2011/08/29/microsoft-is-aligning-with-odbc-for-native-relational-data-access.aspx This makes ODBC the only right choice. :)

0
source

Codesynthesis's C ++ ODB object-relational mapping system can be used by GPL version 2 software.

http://codesynthesis.com/products/odb/

Here is a blog entry in which they describe why they decided to use their own C API instead of ODBC to connect to the databases.

http://codesynthesis.com/~boris/blog/2011/12/09/oci-mingw/

Speed ​​was one of the reasons.

0
source

All Articles