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.
 
 
 
 

30 lines
1018 B

#include <ctime>
#include <db/db.h>
#include <db/statements/builder/SelectStatementBuilder.h>
namespace db {
void fetch_alarms(sql::Database *db, uint32_t interval) {
std::time_t now = std::time(nullptr);
stmt::Statement select_alarms = stmt::Statement::select().columns("dtstart, summary, description").from_table("alarms").inner_join("events", "events.rowid = alarms.eventID").where("dtstart<? AND dtstart>?").close();
DEBUG << select_alarms.str();
try {
sql::Statement query(*db, select_alarms.str());
query.bind(1, now + interval);
query.bind(2, now);
DEBUG << query.getExpandedSQL();
while (query.executeStep())
{
uint32_t dtstart = query.getColumn(0);
std::string summary = query.getColumn(1);
std::string description = query.getColumn(2);
DEBUG << dtstart << ", " << summary << ", " << description;
}
}
catch (std::exception& e)
{
std::cout << "Exception: " << e.what() << std::endl;
}
}
}