From 6a455c09c570cea10bf791fde94ad01d834667b2 Mon Sep 17 00:00:00 2001 From: p95lsv6nx <3160878898@qq.com> Date: Wed, 7 Jun 2023 01:46:07 +0800 Subject: [PATCH] ADD file via upload --- sqlite.h | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 sqlite.h diff --git a/sqlite.h b/sqlite.h new file mode 100644 index 00000000..e60de7ab --- /dev/null +++ b/sqlite.h @@ -0,0 +1,143 @@ +#ifndef SQLITE_H +#define SQLITE_H + +#include +#include +#include +#include +#include +#include +#include + +namespace database +{ + +class sqlite +{ +public: + + sqlite(); + + ~sqlite(); + + QSqlDatabase db;//建立和qt和数据库连接 + QSqlQueryModel model;//保存和遍历select结果 + + int createDB(); + + int createMissionTable(); + + int createRobortTable(); + + int addMission(std::string name, int type); + + std::vector queryMissionROBORT(std::string name) + { + std::vector RobortList; + QString select_sql = "select name, mission from Robort"; + QSqlQuery query; + if(!query.exec(select_sql)) + { + qDebug()< traverseMission(); + + void queryMission(std::string name, int &id, int &type, std::vector &robort) + { + QString select_sql = "select id, name, type from Mission"; + QSqlQuery query; + if(!query.exec(select_sql)) + { + qDebug()<