前言:
I don't really understand why they made a C++ wrapper for the C API (MySQL++ = http://www.tangentsoft.net/mysql++/ ) because shouldn't the C API work in C++?
The mysql C api will work in C++ - I suppose someone just wanted to do a c++ wrapper.
库推荐:
1. SOCI http://soci.sourceforge.net/index.html
SOCI is a database access library for C++ that makes the illusion of embedding SQL queries in the regular C++ code, staying entirely within the Standard C++.
The idea is to provide C++ programmers a way to access SQL databases in the most natural and intuitive way. If you find existing libraries too difficult for your needs or just distracting, SOCI can be a good alternative.
2. MySQL++http://tangentsoft.net/mysql++/
MySQL++ is a C++ wrapper for MySQL’s C API. It is built around the same principles as the Standard C++ Library, to make dealing with the database as easy as dealing with STL containers. In addition, MySQL++ provides facilities that let you avoid the most repetitive sorts of SQL within your own code, providing native C++ interfaces for these common tasks.
个人编写:
1. 借助Boost库
Lean and extensible mySQL C++ wrapper
This article present a lean C++ wrapper of mySQL client. All of the functions are defined in two header files. Users can build the file with mySQL C API library and header files of boost::shared_ptr
which is used to manage the MYSQL connection and result set.
2. http://bogomip.net/blog/2009/08/28/new-c-mysql-wrapper/
3. 不借助外部库
|
Output is:
MySQL Tables in mysql database: 1 John Bartholomew Pippin 2 Thomas Tiberius Tabernathy 3 Delta Echo Gamma |