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
|
/* Programmer's name: Ashton
* Contact info: [HIDDEN]
* Date Created: Nov 20, 2023
* Version: 1.0.0
* Purpose: Handles the python-C++ connection
* Issues: None noticed at the moment
*
*/
#include <iostream>
#include <cstdlib>
#include <cstring>
void Create(std::string hex, std::string val)
{
/*
* Calls the python file to insert the given values into the MySQL
* database.
*/
std::string cmd = "python database.py CREATE ";
cmd += hex;
cmd += " ";
cmd += val;
system(cmd.c_str());
}
void Read(std::string col, std::string val)
{
/*
* Find and print out searched val in a given col.
*/
std::string cmd = "python database.py READ ";
cmd += col;
cmd += " ";
cmd += val;
system(cmd.c_str());
}
void Update(std::string u_col, std::string u_val, std::string u_loc, std::string u_loc_val)
{
/*
* Update column (u_col) with new value (u_val) at a given location (u_loc)
* that contains the value u_loc_val.
*/
std::string cmd = "python database.py UPDATE ";
cmd += u_col;
cmd += " ";
cmd += u_val;
cmd += " ";
cmd += u_loc;
cmd += " ";
cmd += u_loc_val;
system(cmd.c_str());
}
void Delete(std::string col, std::string val)
{
/*
* Deletes an entry with a given value at a given column.
*/
std::string cmd = "python database.py DELETE ";
cmd += col;
cmd += " ";
cmd += val;
system(cmd.c_str());
}
int main()
{
/*
* This is a test file, I will connect it to the program later,
* but for now it's just going to be it's own separate file.
*/
// Tested each of the below. It works fine.
//Create("95", "Alakazam");
//Read("hex", "95");
//Update("name", "alakazam", "hex", "95");
//Delete("hex", "95");
// TODO: I should probably put Read into a variable.
return 0;
}
|