|
|
|
|
@ -6,19 +6,29 @@
|
|
|
|
|
using namespace sql;
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
Driver *driver;
|
|
|
|
|
Connection *con;
|
|
|
|
|
Statement *stmt;
|
|
|
|
|
|
|
|
|
|
void exiting(){
|
|
|
|
|
delete con;
|
|
|
|
|
delete stmt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
crow::SimpleApp app;
|
|
|
|
|
|
|
|
|
|
CROW_ROUTE(app, "/seconds")([](){
|
|
|
|
|
Driver *driver = get_driver_instance();
|
|
|
|
|
Connection *con = driver->connect(getenv("DBURL"),getenv("DBUSER"),getenv("DBPWD"));
|
|
|
|
|
driver = get_driver_instance();
|
|
|
|
|
con = driver->connect(getenv("DBURL"),getenv("DBUSER"),getenv("DBPWD"));
|
|
|
|
|
con->setSchema("timer_backend");
|
|
|
|
|
Statement *stmt = con->createStatement();
|
|
|
|
|
ResultSet *res = stmt->executeQuery("SELECT * FROM sessions;");
|
|
|
|
|
stmt = con->createStatement();
|
|
|
|
|
|
|
|
|
|
CROW_ROUTE(app, "/seconds")([](){
|
|
|
|
|
crow::json::wvalue entries;
|
|
|
|
|
|
|
|
|
|
ResultSet *res = stmt->executeQuery("SELECT * FROM sessions;");
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
while (res->next()) {
|
|
|
|
|
int id = res->getInt("id");
|
|
|
|
|
@ -29,12 +39,11 @@ int main()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete res;
|
|
|
|
|
delete stmt;
|
|
|
|
|
delete con;
|
|
|
|
|
|
|
|
|
|
return entries;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
app.port(18080).run();
|
|
|
|
|
|
|
|
|
|
atexit(exiting);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|