-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
45 lines (30 loc) · 1.03 KB
/
main.cpp
File metadata and controls
45 lines (30 loc) · 1.03 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
#include <iostream>
#include "Database.hpp"
#include "Statement.hpp"
#include "OutputRow.hpp"
int main() {
Database db("test.db");
//Statement stmt = db.prepare("INSERT INTO Test (name, age) VALUES (?, ?);");
Statement stmt = db.prepare("SELECT * FROM Test WHERE name LIKE (?);");
stmt.bind("%%");
OutputRow oRow;
while(stmt.run(&oRow)) {
std::cout << oRow[0].getValueText() << " " << oRow[1].getValueInt() << std::endl;
}
stmt.bind("Will");
while(stmt.run(&oRow)) {
std::cout << oRow[0].getValueText() << " " << oRow[1].getValueInt() << std::endl;
}
Database memory;
Statement create = memory.prepare("CREATE TABLE Asdf (num INTEGER, string VARCHAR(255));");
Statement insert = memory.prepare("INSERT INTO Asdf VALUES ((?), (?));");
Statement output = memory.prepare("SELECT * FROM Asdf;");
create.run();
insert.bind(5);
insert.bind("Billy");
insert.run();
OutputRow asdf;
while(stmt.run(&asdf)) {
std::cout << asdf[0].getValueInt() << " " << asdf[1].getValueText() << std::endl;
}
}