-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
27 lines (23 loc) · 796 Bytes
/
Copy pathmain.cpp
File metadata and controls
27 lines (23 loc) · 796 Bytes
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
#include "database.h"
#include "logger.h"
#include "interactive_mode.h"
int main() {
try {
Logger logger("database.log");
Database db("example.db", &logger);
db.executeQuery("CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT);");
db.executeQuery("INSERT INTO users (name) VALUES ('YALOKGAR'), ('yalo');");
auto rows = db.fetchQuery("SELECT * FROM users;");
for (const auto& row : rows) {
for (const auto& col : row) {
std::cout << col << " ";
}
std::cout << std::endl;
}
interactiveMode(db);
} catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
return 1;
}
return 0;
}