cross-platform SQL DB API c/c++ [closed]
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this questionI am writing a database application in C linux. Currently I work on mysql but later we might migrate to postgres. Therefore my boss has asked my开发者_JAVA百科 to prepare the application to be able to use either of the databases(mysql or postgres).
Is there a free api which I can use for this purpose? Or any suggestion on how best I can do this?
The official answer to that is ODBC.
If you don't like that (and let's face it, no one really does), Qt has a database access module, QtSql. Obviously, this will require you to make heavy use of Qt in your application.
If you can find drivers for your platform, ODBC was supposedly meant to provide exactly this: a platform-independent way to talk to databases.
(I say supposedly because in my experience, ODBC is such a mess that hooking up to an ODBC driver once turned out to be more difficult than just writing the code three times for three different databases.)
精彩评论