From 6f8c9754893feb196a28b65351ce517b06c409bc Mon Sep 17 00:00:00 2001 From: "Rajdeep Mehra (mehrar)" Date: Fri, 15 Oct 2021 22:55:01 +0100 Subject: [PATCH] Update and rename login and select to create1_db.h --- create1_db.h | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ login and select | 34 --------------------------------- 2 files changed, 49 insertions(+), 34 deletions(-) create mode 100644 create1_db.h delete mode 100644 login and select diff --git a/create1_db.h b/create1_db.h new file mode 100644 index 0000000..4176b08 --- /dev/null +++ b/create1_db.h @@ -0,0 +1,49 @@ +#ifndef CREATE1_DB_H +#define CREATE1_DB_H +#include +#include +#include + + + +int callback(void *NotUsed, int len, char **value, char **column){ + + for(int i = 0; i < len; i++) { + cout << column[i] << ": " << value[i] << endl; + + } + return 0; +} + +int create1_db() {/* creating a timetable for the student*/ + sqlite3 *db; + char *column = 0; + int load; + string sql; + load = sqlite3_open("Timetable.db", &db); + + if(load){ + cout << "DB Error: " << sqlite3_errmsg(db) << endl; + sqlite3_close(db); + return(1); + } + + sql = "DROP TABLE LESSON;"; + + load = sqlite3_exec(db, sql.c_str(), callback, 0, &column); + + sql = "CREATE TABLE LESSON (" \ + "studentID INT NOT NULL," \ + "modules STR NOT NULL,"\ + "classes STR NOT NULL,"\ + "students STR NOT NULL,"\ + "lecturers STR NOT NULL,"\ + "Timing int NOT NULL,"\ + "rooms STR NOT NULL);"; + + load = sqlite3_exec(db, sql.c_str(), callback, 0, &column); + sqlite3_close(db); + + return 0; +} +#endif diff --git a/login and select b/login and select deleted file mode 100644 index f52fc03..0000000 --- a/login and select +++ /dev/null @@ -1,34 +0,0 @@ -int secondentry(){ /*login your details and check to see if they match the database*/ -cout << "Please enter your student details to Login :" <> log1; -cout << "Password Please :" <> pass1; -sqlite3 *db; -char *column = 0; -int load; -string sql; - -load = sqlite3_open("School.db", &db); - -if(load){ - cout << "DB Error: " << sqlite3_errmsg(db) << endl; - sqlite3_close(db); - return(1); -} - - - - -sql = "SELECT password FROM STUDENTDETAILS " + username + ";"; -load = sqlite3_exec(db, sql.c_str(), callback, 0, &column); - -if (pass1 == sql){ - cout << "Successfull Login" <