diff --git a/src/sql3.cpp b/src/sql3.cpp index 3724657..fa1f415 100644 --- a/src/sql3.cpp +++ b/src/sql3.cpp @@ -7,6 +7,7 @@ sql3::sql3(const string _path, bool _keepOpen) { if (keepOpen) { if (open()) { printf("[ERROR] Ne mogu otvoriti bazu podataka!"); + exit(1); } } @@ -24,6 +25,14 @@ bool sql3::close() { } bool sql3::run(const string sql_command) { + + if (!keepOpen) { + if (open()) { + printf("[ERROR] Ne mogu otvoriti bazu podataka!"); + exit(1); + } + } + bool r = true; char *messaggeError; uint exec_stuts; @@ -38,6 +47,12 @@ bool sql3::run(const string sql_command) { Answer = responseDatabase; } + if (!keepOpen) { + if(close()) { + printf ("ERROR Zatvaranja baze podataka!"); + } + } + return r; } diff --git a/test/test.cpp b/test/test.cpp index 9b8cf32..e4f0d96 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -6,7 +6,7 @@ using namespace std; int main() { - sql3 mydb("../example/example.db", true); + sql3 mydb("../example/example.db", false); //cout << mydb.ask("Select * from Tab1"); // cout << mydb.ask("INSERT INTO Tab1 VALUES(3,'Pakora', 'marijanab@bitelex.ml');"); diff --git a/test/test.o b/test/test.o index a601bab..b364b55 100755 Binary files a/test/test.o and b/test/test.o differ