-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMySQLDB.h
More file actions
84 lines (61 loc) · 1.54 KB
/
Copy pathMySQLDB.h
File metadata and controls
84 lines (61 loc) · 1.54 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
/*
* MySQLDB.h
*
* Created on: 2016Äê5ÔÂ23ÈÕ
* Author: user
*/
#ifndef MYSQLDB_H_
#define MYSQLDB_H_
#include <mysql.h>
#include <iostream>
using namespace std;
#include <mysql.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
MYSQL * InitializeMySQLClient(MYSQL * conn);
MYSQL * ConnectMySQLServer(MYSQL *conn);
int MySQLQuery(MYSQL * conn, const char * sql);
void CloseMySQLConnnection(MYSQL * conn);
/*void MySqlTest()
{
MYSQL * conn_ptr = NULL;
MYSQL_RES * res;
MYSQL_ROW row;
char * host = "127.0.0.1";
char * user = "root";
char * password = "";
char * db = "mysql";
unsigned int port = 3306;
char * unix_socket = NULL;
unsigned long client_flag = 0;
conn_ptr = mysql_init(conn_ptr);
if(!conn_ptr)
{
fprintf(stderr, "init mysql failed\n");
fprintf(stderr, "Connection failed....%d: %s\n", errno, strerror(errno));
exit(-1);
}
conn_ptr = mysql_real_connect(conn_ptr, host, user, password, db, port, unix_socket, client_flag);
if(conn_ptr)
{
printf("Connection Success...\n");
}
else
{
fprintf(stderr, "Connection failed....%d: %s\n", errno, strerror(errno));
}
if(mysql_query(conn_ptr, "select host, user from user"))
{
fprintf(stderr, "call mysql_query failed...%d: %s", errno, strerror(errno));
}
res = mysql_use_result(conn_ptr);
while((row = mysql_fetch_row(res)))
{
fprintf(stdout, "%s\t%s\n", row[0], row[1]);
}
mysql_free_result(res);
mysql_close(conn_ptr);
return;
}*/
#endif /* MYSQLDB_H_ */