customer can be saved into db

This commit is contained in:
MassiveAtoms
2019-06-26 15:12:23 -03:00
parent 2e22008040
commit f11ebc6a9c
7 changed files with 75 additions and 36 deletions

View File

@ -1,5 +1,5 @@
#include "headers/Park_spot.h"
#include "thirdparty/SQLiteCpp/include/SQLiteCpp/SQLiteCpp.h"
#include "headers/data.h"
#include <iostream>
#include <thread> // to make pausing work, not sure if i need chrono, or this, or both
#include <vector>
@ -30,18 +30,11 @@ a wait function where 1 sec represents 1 hour irl.
using std::cout;
int main() {
SQLite::Database db("test.db3", SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE);
db.exec("create table if not exists Customer (id integer primary key, name text, card_code varchar(20), verhicle int)");
db.exec("create table if not exists Park_spot (id integer primary key, taken boolean, customer_id int)");
db.exec("create table if not exists Park_time (id integer primary key, customer_id int, spot_id int, start real, end real, duration real)");
SQLite::Transaction transaction(db);
db.exec("insert into Customer values (NULL, 'sagar ram', 'aqwsderfgtaqwsderfgt', 2)");
transaction.commit();
SQLite::Database db = data::start_db();
// search example
SQLite::Statement get_sagar(db, "select * from Customer where name like '%sagar%' ");
while (get_sagar.executeStep()) {
int id = get_sagar.getColumn(0);
string name = get_sagar.getColumn(1);
@ -49,4 +42,7 @@ int main() {
int car = get_sagar.getColumn(3);
cout << id << "," << name << "," << code << "," << car << std::endl;
}
Customer sagar{15, "Ramsaransing", Verhicle_type::medium};
sagar.update_db(db);
}