Skip to content
Permalink
Browse files
Update and rename create database to create_db.h
  • Loading branch information
mehrar committed Oct 15, 2021
1 parent 7b25ee7 commit d053a7859e398c75b16c4cdd59d835740c092a06
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 89 deletions.

This file was deleted.

@@ -0,0 +1,46 @@
#ifndef CREATE_DB_H
#define CREATE_DB_H
#include <iostream>
#include <string>
#include <sqlite3.h>



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 create_db(int len, char* value[]) {/*creating a database for the timetable*/
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);
}

load = sqlite3_exec(db, sql.c_str(), callback, 0, &column);

sql = "CREATE TABLE STUDENTDETAILS (" \
"studentID INT PRIMARY KEY NOT NULL," \
"name STR NOT NULL,"\
"surname STR NOT NULL,"\
"username STR NOT NULL,"\
"email STR NOT NULL,"\
"password STR NOT NULL);";

load = sqlite3_exec(db, sql.c_str(), callback, 0, &column);
sqlite3_close(db);

return 0;
}

0 comments on commit d053a78

Please sign in to comment.