File tree 1 file changed +39
-0
lines changed
1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -1646,6 +1646,45 @@ delete conn;
1646
1646
conn = NULL;
1647
1647
</source>
1648
1648
1649
+ <h4>MySQL++</h4>
1650
+
1651
+ Home:[http://www.tangentsoft.net/mysql%2B%2B/]
1652
+
1653
+ 这是个老牌的库,诞生于1998年,提供了 MySQL API 的 C++ 封装。
1654
+
1655
+ 代码示例——执行 SQL 语句
1656
+ <source lang="cpp">
1657
+ #include <iostream>
1658
+ #include <mysql++.h>
1659
+
1660
+ void query(db_name, server_name, user, password)
1661
+ {
1662
+ using namespace std;
1663
+
1664
+ mysqlpp::Connection conn(false);
1665
+ if(!conn.connect(db_name, server_name, user, password))
1666
+ {
1667
+ cerr << "DB connection failed: " << conn.error() << endl;
1668
+ return;
1669
+ }
1670
+
1671
+ mysqlpp::Query query = conn.query("select item from table1");
1672
+ mysqlpp::StoreQueryResult sqr = query.store()
1673
+ if(!sqr)
1674
+ {
1675
+ cerr << "Failed to get item list: " << query.error() << endl;
1676
+ return;
1677
+ }
1678
+
1679
+ mysqlpp::StoreQueryResult::const_iterator iter;
1680
+ for(iter=sqr.begin(); iter!=sqr.end(); ++iter)
1681
+ {
1682
+ mysqlpp::Row row = *iter;
1683
+ cout << '\t' << row[0] << endl;
1684
+ }
1685
+ }
1686
+ </source>
1687
+
1649
1688
<h4>POCO::Data::MySQL</h4>
1650
1689
1651
1690
Docs:[http://pocoproject.org/docs/package-MySQL.MySQL.html]
You can’t perform that action at this time.
0 commit comments