Add callback response string clear, and throw string
This commit is contained in:
parent
0b5ed3f47b
commit
f6c8443c5d
@ -22,7 +22,6 @@ class sql3 {
|
|||||||
sqlite3* db;
|
sqlite3* db;
|
||||||
string path;
|
string path;
|
||||||
bool keepOpen;
|
bool keepOpen;
|
||||||
// map<string, vector<string>> model;
|
|
||||||
string Answer;
|
string Answer;
|
||||||
map<string, vector<string>> parsed;
|
map<string, vector<string>> parsed;
|
||||||
|
|
||||||
|
13
src/sql3.cpp
13
src/sql3.cpp
@ -6,7 +6,7 @@ sql3::sql3(const string _path, bool _keepOpen) {
|
|||||||
|
|
||||||
if (keepOpen) {
|
if (keepOpen) {
|
||||||
if (open()) {
|
if (open()) {
|
||||||
throw "[ERROR] Unable to open database ";
|
throw string("[ERROR] Unable to open database ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ bool sql3::run(const string sql_command) {
|
|||||||
|
|
||||||
if (!keepOpen) {
|
if (!keepOpen) {
|
||||||
if (open()) {
|
if (open()) {
|
||||||
throw "[ERROR] Unable to open database ";
|
throw string("[ERROR] Unable to open database ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ bool sql3::run(const string sql_command) {
|
|||||||
|
|
||||||
if (!keepOpen) {
|
if (!keepOpen) {
|
||||||
if(close()) {
|
if(close()) {
|
||||||
throw "[ERROR] Unable to close database ";
|
throw string("[ERROR] Unable to close database ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ string sql3::answer() {
|
|||||||
|
|
||||||
string sql3::ask(const string sql_command) {
|
string sql3::ask(const string sql_command) {
|
||||||
if (!run(sql_command)) {
|
if (!run(sql_command)) {
|
||||||
throw "[ERROR] Unable to read database ";
|
throw string("[ERROR] Unable to read database ");
|
||||||
//return {};
|
//return {};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -72,7 +72,7 @@ string sql3::ask(const string sql_command) {
|
|||||||
|
|
||||||
map<string, vector<string>> sql3::query(const string sql_command) {
|
map<string, vector<string>> sql3::query(const string sql_command) {
|
||||||
if (!run(sql_command)) {
|
if (!run(sql_command)) {
|
||||||
throw "[ERROR] Unable to read database ";
|
throw string("[ERROR] Unable to read database ");
|
||||||
//return {};
|
//return {};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -104,7 +104,7 @@ void sql3::mapit() {
|
|||||||
|
|
||||||
sql3::~sql3() {
|
sql3::~sql3() {
|
||||||
if(close()) {
|
if(close()) {
|
||||||
throw "[ERROR] Unable to close database ";
|
throw string("[ERROR] Unable to close database ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,6 +117,7 @@ static int callback(void* data, int argc, char** argv, char** azColName) {
|
|||||||
int i;
|
int i;
|
||||||
fprintf(stderr, "%s: ", (const char*)data);
|
fprintf(stderr, "%s: ", (const char*)data);
|
||||||
char res[1000];
|
char res[1000];
|
||||||
|
responseDatabase.clear();
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
sprintf(res, "%s = %s", azColName[i], argv[i] ? argv[i] : "NULL");
|
sprintf(res, "%s = %s", azColName[i], argv[i] ? argv[i] : "NULL");
|
||||||
responseDatabase += res;
|
responseDatabase += res;
|
||||||
|
BIN
test/test.o
BIN
test/test.o
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user