|
|
@ -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; |
|
|
|