diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2018-08-30 14:24:52 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2018-08-30 14:24:52 +0200 |
commit | b99017a7938cb36e234025d9ae592bac06ec3ec6 (patch) | |
tree | 804e5122850b14740adac5fed6d2a16ab8ae7654 | |
parent | 9d86377c9d10c48c2fb583d0a8cf2874d7ab4082 (diff) | |
download | ble-toys-b99017a7938cb36e234025d9ae592bac06ec3ec6.tar.gz ble-toys-b99017a7938cb36e234025d9ae592bac06ec3ec6.tar.bz2 ble-toys-b99017a7938cb36e234025d9ae592bac06ec3ec6.tar.xz ble-toys-b99017a7938cb36e234025d9ae592bac06ec3ec6.zip |
sm-db-insert: fixing headers and warnings.
-rw-r--r-- | apps/sm-db-insert.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/apps/sm-db-insert.cpp b/apps/sm-db-insert.cpp index 57a633c..46a64e2 100644 --- a/apps/sm-db-insert.cpp +++ b/apps/sm-db-insert.cpp @@ -1,7 +1,7 @@ #include <boost/lexical_cast.hpp> +#include <pqxx/result_iterator.hxx> #include <pqxx/connection.hxx> #include <pqxx/transaction.hxx> -#include <pqxx/result_iterator.hxx> #include <json.hpp> #include "apps.h" #include <fstream> @@ -16,7 +16,7 @@ class sm_db_insert : public app { public: sm_db_insert() : app("sm-db-insert") {} - ~sm_db_insert() = default; + ~sm_db_insert() override = default; void add_options(po::options_description_easy_init &options) override { options("file", po::value<string>()->required(), "The file to read"); @@ -41,7 +41,7 @@ public: auto select_device = "select id from soil_moisture_device where mac=$1"; auto rs = work.parameterized(select_device)(mac).exec(); - if (!rs.size()) { + if (rs.empty()) { cout << "New device: " << mac << endl; auto insert_device = "insert into soil_moisture_device(mac) values($1) returning id"; @@ -55,7 +55,7 @@ public: auto select_sensor = "select id from soil_moisture_sensor where device=$1 and sensor=$2"; rs = work.parameterized(select_sensor)(deviceId)(sensor).exec(); - if (!rs.size()) { + if (rs.empty()) { cout << "New sensor: " << sensor << endl; auto insert_sensor = "insert into soil_moisture_sensor(device, sensor) values($1, $2) returning id"; @@ -63,8 +63,8 @@ public: } auto sensorId = rs.begin()["id"].as<int>(); - unsigned long timestamp = get<unsigned long>(j, "timestamp"); - unsigned int value = get<unsigned int>(j, "value"); + auto timestamp = get<unsigned long>(j, "timestamp"); + auto value = get<unsigned int>(j, "value"); auto insert_sample = "insert into soil_moisture_sample(sensor, timestamp, value) values($1, $2, $3)"; work.parameterized(insert_sample)(sensorId)(timestamp)(value).exec(); |