Which option to select to use sql in C++ [closed] Which option to select to use sql in C++ [closed] database database

Which option to select to use sql in C++ [closed]


The main questions you need to consider are how cross-platform you need to be, both on the application, and the database side.

If you need to connect potentially to more than one relational database server (e.g. Oracle and MySQL or Firebird), you are likely to be better off using ODBC (for what it's worth I use UnixODBC). I haven't used SQLAPI++ or SOCI so I can't say much about how these compare to UnixODBC.

With UnixODBC, you get quite a lot of choice in deployment. Quite often, I don't actually install UnixODBC at all, and instead connect an application directly to the ODBC driver (this is useful if a particular instance is only going to be talking to a single database, and minimises the stuff you need to install). It also works with both C++ and C.

With UnixODBC -> MS SQL Server, we use the FreeTDS driver. Initially I was worried going into production with this, but in fact I found out the wire protocol is fully specified so this is more than a reverse engineered hack (and also I believe the same guys who make FreeTDS also do the commercial EasySoft drivers). MySQL provides UnixODBC compatible drivers themselves.

I haven't tried UnixODBC -> Oracle, as I had already written a direct OCI (instant client) interface and we have always used this.

UnixODBC is very slightly slower than using a wire-protocol approach like OCI, but the difference isn't significant enough to worry about. The reason we use OCI is that Oracle provide it free for Linux / AIX / Solaris platforms, while I couldn't find ODBC oracle drivers for these platforms.