customer can be saved into db
This commit is contained in:
16
main.cpp
16
main.cpp
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user