-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.cpp
39 lines (31 loc) · 1008 Bytes
/
example.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include "utils.hpp"
#include "connection_info.hpp"
#include "sql/query.hpp"
int main(){
std::string connection_info_ ="mysql:host=127.0.0.1;port=3306;user=root;password=root;database=girls;";
cppdb::pool_manager::init(connection_info_);
/*
// 不需要返回值的时候
cppdb::query<
"insert into boys(boyName,userCP) VALUES('?',?);"
, void> q;
q << "audi2" << 300 << cppdb::exec;
*/
//行 接收一行的信息
using boysRow =
cppdb::row_type<
cppdb::column<"boyName", std::string>,
cppdb::column<"userCP", int>
>;
cppdb::query<"select boyName,userCP from boys;", boysRow> q_row;
boysRow boyrow_1 = q_row << cppdb::exec;
//输出
std::cout << cppdb::get<"boyName",boysRow>(boyrow_1) << std::endl;
std::cout << cppdb::get<"userCP",boysRow>(boyrow_1) << std::endl;
//std::cout << "res1 :" << res1 << std::endl;
//query
//del
//update
return 0;
}