From 896a5cd55df9590aee315b61e193281ede1a6b48 Mon Sep 17 00:00:00 2001 From: MassiveAtoms Date: Mon, 24 Jun 2019 22:09:43 -0300 Subject: [PATCH] fix open_db --- db.cpp | 12 +++++------- main.cpp | 36 +----------------------------------- 2 files changed, 6 insertions(+), 42 deletions(-) diff --git a/db.cpp b/db.cpp index 8792572..182fe97 100644 --- a/db.cpp +++ b/db.cpp @@ -14,8 +14,9 @@ static int callback(void* NotUsed, int argc, char** argv, char** azColName) { } void open_db(sqlite3* db) { - int status = sqlite3_open("database.sqlite", &db); - if (!status) { + int status = sqlite3_open("database.sqlite", &db); // for some reason, 0 is pass and 1 is erroring out + // so it prolly shouldn't be called status + if (status) { std::cout << "Can't open database: " << sqlite3_errmsg(db) << "\n"; } } @@ -23,12 +24,9 @@ void open_db(sqlite3* db) { void initialize_db(sqlite3* db) { // ugh, sqlite3_exec doesn't accept const strings, so i have to use const // char* - const char* customer_table = "create table Customer (id int, name " - "varchar(50), card_code varchar(20), " - "verhicle int)"; + const char* customer_table = "create table Customer (id int, name varchar(50), card_code varchar(20), verhicle int)"; const char* parkspot_table = "create table Park_spot (id int, taken boolean, customer_id int)"; - const char* parktime_table = "create table Park_time (id int, customer_id int, spot_id int, start " - "real, end real, duration real)"; + const char* parktime_table = "create table Park_time (id int, customer_id int, spot_id int, start real, end real, duration real)"; int success; success = sqlite3_exec(db, customer_table, callback, 0, &error_message); diff --git a/main.cpp b/main.cpp index 5de74ad..85751d9 100644 --- a/main.cpp +++ b/main.cpp @@ -30,45 +30,11 @@ a wait function where 1 sec represents 1 hour irl. using std::cout; int main() { - std::vector spots{1, 2, 3, 4, 5}; - std::vector customers{ - {1, "Sagar Ram", Verhicle_type::small}, {2, "Shaq", Verhicle_type::medium}, {3, "Josh", Verhicle_type::large}, {4, "Stefano", Verhicle_type::small}}; - - // spots[1].clock(&customers[3]); // stefano parks at spot 2 - // Wait(2); - // spots[3].clock(&customers[2]); // josh parks at spot 4 - // Wait(1); - // spots[1].clock(&customers[3]); // stefano clocks out of spot 1 - // Wait(5); - // spots[1].clock(&customers[1]); // shaq clocks in at spot 1 - // Wait(6); - // spots[2].clock(&customers[0]); // sagar clocks in at spot 3. what the fuck - // // is he doing here? - // Wait(2); - // spots[2].clock(&customers[0]); // sagar clocks out from spot 2 - // Wait(3); - // spots[3].clock(&customers[2]); // josh clocks out from spot 4 - // spots[1].clock(&customers[1]); // shaq clocks out at spot 1 - - // spots[2].clock(&customers[1]); // shaq clocks out at spot 3 - // Wait(4); - // spots[2].clock(&customers[1]); // shaq clocks out at spot 2 - - /* - so: - stefan parked for 3 secs - josh parked for 17 secs - shaq parked 2 times, once for 4 and another for 11 secs - sagar parked for 2 secs - */ - customers[0].gen_monthly(); - customers[1].gen_monthly(); - customers[2].gen_monthly(); - customers[3].gen_monthly(); // test sqlite3* db; data::open_db(db); + cout << "PASS"; data::initialize_db(db); sqlite3_close(db); }