A library for MySQL that implements a simpler framework for MySQL Connector++
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mySQL/test/test.cpp

99 lines
2.5 KiB

1 year ago
#include <iostream>
#include <thread>
#include <chrono>
1 year ago
#include "../lib/mysql.hpp"
using namespace std;
using namespace chrono;
1 year ago
int main() {
try {
mySQL mydb("tcp://192.168.2.10:3306", "dinio", "H€r5elfInd1aH@nds", "dinio", true, 3);
auto start = high_resolution_clock::now();
thread t1([&](){
try {
sqlQA test_qa;
test_qa.select().from("records").where("enabled = 1");
mydb.exec(test_qa);
test_qa.print(true);
} catch (const string err) {
cout << err << endl;
}
});
thread t2([&](){
try {
sqlQA test_qa;
test_qa.select().from("zones");
mydb.exec(test_qa);
test_qa.print(true);
} catch (const string err) {
cout << err << endl;
}
});
thread t3([&](){
try {
sqlQA test_qa;
test_qa.select().from("users");
mydb.exec(test_qa);
test_qa.print(true);
} catch (const string err) {
cout << err << endl;
}
});
t1.join();
t2.join();
t3.join();
// one by one
// try {
// sqlQA test_qa;
// test_qa.select().from("records").where("enabled = 1");
// mydb.exec(test_qa);
// test_qa.print(true);
// } catch (const string err) {
// cout << err << endl;
// }
// try {
// sqlQA test_qa;
// test_qa.select().from("users");
// mydb.exec(test_qa);
// test_qa.print(true);
// } catch (const string err) {
// cout << err << endl;
// }
// try {
// sqlQA test_qa;
// test_qa.select().from("users");
// mydb.exec(test_qa);
// test_qa.print(true);
// } catch (const string err) {
// cout << err << endl;
// }
auto end = high_resolution_clock::now();
auto duration = duration_cast<microseconds>(end - start);
cout << "-------------Izvršilo se za: " << (double)(duration.count() / 1000.0) << " ms"<< endl;
} catch (const SQLException error) {
1 year ago
cout << error.what() << endl;
} catch (const string error) {
cout << error << endl;
} catch (...) {
cout << "Jebi ga" << endl;
1 year ago
}
return 0;
}