Skip to content

Commit 2d069c2

Browse files
committed
增加 MySQL++
1 parent 01e530d commit 2d069c2

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

libs/cpp.wiki

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,6 +1646,45 @@ delete conn;
16461646
conn = NULL;
16471647
</source>
16481648

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+
&#35;include <iostream>
1658+
&#35;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+
16491688
<h4>POCO::Data::MySQL</h4>
16501689

16511690
Docs:[http://pocoproject.org/docs/package-MySQL.MySQL.html]

0 commit comments

Comments
 (0)