-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
100 lines (86 loc) · 2.56 KB
/
main.cpp
File metadata and controls
100 lines (86 loc) · 2.56 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* =====================================================================================
*
* Filename: main.cpp
*
* Description:
*
* Version: 1.0
* Created: 2016/8/15 11:08:21
* Revision: none
* Compiler: gcc
*
* Author: wangxinxin, winer632@qq.com
* Organization: lj
*
* =====================================================================================
* ============================== CHANGE REPORT HISTORY ================================
* | VERSION | UPDATE DATE | UPDATED BY | DESCRIPTION OF CHANGE |*
* =========================== END OF CHANGE REPORT HISTORY ============================
*/
/*
preinstall:
yum install -y boost boost-devel boost-doc
*/
#include <stdio.h>
#include "mysqlconn_wrapper.h"
const std::string currentDateTime() {
time_t now = time(0);
struct tm tstruct;
char buf[80];
tstruct = *localtime(&now);
// Visit http://en.cppreference.com/w/cpp/chrono/c/strftime
// for more information about date/time format
strftime(buf, sizeof(buf), "%Y-%m-%d.%X", &tstruct);
return buf;
}
int main(int argc, char *argv[])
{
MySQLConnWrapper db;
db.init("127.0.0.1:11008", "root", "fdjkd&wi278^@6DGHfyTF");
db.connect();
db.switchDb("mihao");
char buffer [50];
sprintf(buffer, "UPDATE active_user SET fd=%d", 11);
db.prepare(buffer);
db.executeUpdate();
db.delete_prepare();
#if 0
db.prepare("INSERT INTO active_user(create_time, mdn, imsi, esn) VALUES (?, ?, ?, ?)");
string now=currentDateTime();
db.setString(1,now);
db.setString(2,"13301602770");
db.setString(3, "6160761796");
db.setString(4, "80D8852E");
db.executeUpdate();
db.setString(1,now);
db.setString(2,"13301605333");
db.setString(3, "0911785312");
db.setString(4, "0911785312");
db.executeUpdate();
db.setString(1,now);
db.setString(2,"13301605371");
db.setString(3, "6301743459");
db.setString(4, "8094016C");
db.executeUpdate();
char mdn[]="13301602770";
char sql[100];
sprintf(sql,"delete from active_user where mdn=%s",mdn);
db.executeUpdate(sql);
//db.closeCon();
//db.executeQuery("select * from active_user where mdn=13301602770");
db.executeQuery("select * from active_user");
db.closeCon();
while(db.fetch()){
string create_time=db.getString("create_time");
printf("create_time=%s\n", create_time.c_str());
string mdn=db.getString("mdn");
printf("mdn=%s\n", mdn.c_str());
string imsi=db.getString("imsi");
printf("imsi=%s\n", imsi.c_str());
string esn=db.getString(3);
printf("esn=%s\n", esn.c_str());
}
#endif
return 0;
}