Files

83 lines
1.9 KiB
C++
Raw Permalink Normal View History

2025-03-04 10:49:05 +08:00
/**
* @brief
*
* 普通数据库表结构 normal_data_table
* pn | id | stime | source | crc | class_id | value
*/
#include "normalDataDB.h"
CNormalDB::CNormalDB(void* handle)
{
m_db = handle;
}
bool CNormalDB::createDataTable(void)
{
bool fRet=false;
/*
std::string sql = "create table " ;
std::string tableName = "normal_data";
std::string columnStr = " (pn int, id char(8), stime int, dtime int, source char(32), value blob, primary key(pn, id)); ";
sql = sql+tableName+columnStr;
sqlite3_stmt *stmt=NULL;
if (sqlite3_exec((sqlite3*)m_db, sql.c_str(), NULL, 0, NULL)==SQLITE_OK){
}else{
printf("create file data table fail error %s\n", sqlite3_errmsg(m_sdb));
}
*/
return fRet;
}
bool CNormalDB::readData(const json &cdt, json &outjv)
{
/*
std::string sql = "select " ;
std::string columnStr = "(pn , id , stime , source , value) from ";
std::string tableName = "normal_data";
sql = sql+tableName+columnStr;
sqlite3_stmt *stmt=NULL;
if (sqlite3_exec((sqlite3*)m_db, sql.c_str(), NULL, 0, NULL)==SQLITE_OK){
}else{
printf("create file data table fail error %s\n", sqlite3_errmsg(m_sdb));
}
*/
return true;
}
bool CNormalDB::writeData(const json &wjv, json &outjv)
{
/*
std::string sql = "insert into " ;
std::string tableName = " normal_data ";
std::string columnStr = " (pn , id , stime , dtime , source , value ) ";
std::string valueStr = "(" + wjv["pn"].get<std::string>() + wjv["id"].get<std::string>()
+ wjv["stime"].get<std::string>() + wjv["dtime"].get<std::string>() + wjv["source"].get<std::string>() +
wjv["value"].get<std::string>() + ")" ;
sql = sql + tableName + columnStr + " values " + valueStr;
sqlite3_stmt *stmt=NULL;
if (sqlite3_exec((sqlite3*)m_db, sql.c_str(), NULL, 0, NULL)==SQLITE_OK){
}else{
printf("create file data table fail error %s\n", sqlite3_errmsg(m_sdb));
}
*/
return true;
}