Initial commit
This commit is contained in:
commit
d17500a3b0
18 changed files with 938 additions and 0 deletions
32
models/device_dbo.cc
Normal file
32
models/device_dbo.cc
Normal file
|
@ -0,0 +1,32 @@
|
|||
//
|
||||
// Created by tobias on 08/07/19.
|
||||
//
|
||||
|
||||
#include <cstdio>
|
||||
#include "device_dbo.h"
|
||||
#include "globals.h"
|
||||
|
||||
bool device_dbo::save()
|
||||
{
|
||||
int rc;
|
||||
sqlite3_stmt *stmt;
|
||||
|
||||
//sqlite3_prepare_v2(db, "INSERT INTO devices(id, name, ip, active) values (?1, ?2, ?3, ?4);", -1, &stmt, nullptr);
|
||||
sqlite3_prepare_v2(globals::db, "UPDATE devices set name = ?2, ip = ?3, active = ?4 WHERE id = ?1;", -1, &stmt, nullptr);
|
||||
|
||||
sqlite3_bind_text(stmt, 1, this->id, -1, SQLITE_STATIC);
|
||||
sqlite3_bind_text(stmt, 2, this->name, -1, SQLITE_STATIC);
|
||||
sqlite3_bind_text(stmt, 3, this->ip, -1, SQLITE_STATIC);
|
||||
sqlite3_bind_int(stmt, 4, this->active);
|
||||
//sqlite3_bind_int(stmt, 2, 21);
|
||||
|
||||
rc = sqlite3_step(stmt);
|
||||
if (rc != SQLITE_DONE) {
|
||||
printf("ERROR inserting data: %s\n", sqlite3_errmsg(globals::db));
|
||||
return false;
|
||||
}
|
||||
|
||||
sqlite3_finalize(stmt);
|
||||
|
||||
return true;
|
||||
}
|
21
models/device_dbo.h
Normal file
21
models/device_dbo.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
#ifndef EMGAUWA_CORE_DEVICE_DBO_H
|
||||
#define EMGAUWA_CORE_DEVICE_DBO_H
|
||||
|
||||
#include <string>
|
||||
#include <sqlite3.h>
|
||||
|
||||
class device_dbo
|
||||
{
|
||||
public:
|
||||
char id[23];
|
||||
char name[128];
|
||||
char ip[17];
|
||||
bool active;
|
||||
int port;
|
||||
int relay_count;
|
||||
|
||||
bool save();
|
||||
};
|
||||
|
||||
|
||||
#endif //EMGAUWA_CORE_DEVICE_DBO_H
|
15
models/model.template.json
Normal file
15
models/model.template.json
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
//rdbms:server type, postgresql,mysql or sqlite3
|
||||
"rdbms":"postgresql",
|
||||
//filename:sqlite3 db file name
|
||||
//"filename":"",
|
||||
//host:server address,localhost by default;
|
||||
"host":"127.0.0.1",
|
||||
//port:server port, 5432 by default;
|
||||
"port":5432,
|
||||
//dbname:Database name;
|
||||
"dbname":"",
|
||||
"user":"",
|
||||
"passwd":"",
|
||||
"tables":[]
|
||||
}
|
5
models/schedule_dbo.cc
Normal file
5
models/schedule_dbo.cc
Normal file
|
@ -0,0 +1,5 @@
|
|||
//
|
||||
// Created by tobias on 09/07/19.
|
||||
//
|
||||
|
||||
#include "schedule_dbo.h"
|
15
models/schedule_dbo.h
Normal file
15
models/schedule_dbo.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
//
|
||||
// Created by tobias on 09/07/19.
|
||||
//
|
||||
|
||||
#ifndef EMGAUWA_CORE_SCHEDULE_DBO_H
|
||||
#define EMGAUWA_CORE_SCHEDULE_DBO_H
|
||||
|
||||
|
||||
class schedule_dbo
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //EMGAUWA_CORE_SCHEDULE_DBO_H
|
Loading…
Add table
Add a link
Reference in a new issue