In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains how to use SmartDb in C++. Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "how to use SmartDb in C++"!
Sqlite is a very lightweight open source database, used in embedded systems more often, storage management data is very convenient, Sqlite library based on C language API, use up is also quite simple, but there is a little bad API use up a little cumbersome, in addition to different occasions, code reuse rate is very low, have to rewrite the code, increase the workload, code to reuse as much as possible, only valuable. SmartDB encapsulates sqlite in a layer (template metaprogramming based on C++11), shielding us from many details, making it easy to use. Performance and flexibility are balanced with ease of use.
Using SmartDb to manipulate the database is much easier:
Take a look at the sample code:
void TestPerformance(){ SmartDB db; db.Open("test.db"); //Open database const string sqlcreat = "CREATE TABLE if not exists TestInfoTable(ID INTEGER NOT NULL, KPIID INTEGER, CODE INTEGER, V1 INTEGER, V2 INTEGER, V3 REAL, V4 TEXT);"; if (! db. Execute (sqlcreate)) //Execute sql statements return;
const string sqlinsert = "INSERT INTO TestInfoTable(ID, KPIID, CODE, V1, V2, V3, V4) VALUES(?, ?, ?, ?, ?, ?, ?); "; bool ret = db.Prepare(sqlinsert); db.Begin(); for (size_t i = 0; i
< 10; i++) //00000 { ret = db.ExcecuteArgs(i, i, i, i, i, i + 1.25, "it is a test"); if (!ret) break; } if (ret) db.Commit(); //提交事务 else db.RollBack(); //回滚 auto p = db.Query("select * from TestInfoTable"); rapidjson::StringBuffer buffer; rapidjson::PrettyWriter pretty_writer(buffer); //PrettyWriter是格式化的json,如果是Writer则是换行空格压缩后的json p->Accept(pretty_writer); //Print to screen cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.