Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
resittimtable/create1_db.h
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
50 lines (37 sloc)
1.11 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef CREATE1_DB_H | |
#define CREATE1_DB_H | |
#include <iostream> | |
#include <string> | |
#include <sqlite3.h> | |
int callback1(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 database for the timetable*/ | |
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 Work;"; | |
load = sqlite3_exec(db, sql.c_str(), callback, 0, &column); | |
sql = "CREATE TABLE Work (" \ | |
"studentID INT NOT NULL," \ | |
"modules STR NOT NULL,"\ | |
"classes STR NOT NULL,"\ | |
"lecturers STR NOT NULL,"\ | |
"rooms STR NOT NULL,"\ | |
"startTiming INT NOT NULL,"\ | |
"endTiming INT NOT NULL);"; | |
load = sqlite3_exec(db, sql.c_str(), callback, 0, &column); | |
sqlite3_close(db); | |
return 0; | |
} | |
#endif |