Skip to content
Permalink
Browse files
Complete
  • Loading branch information
kpakolj committed Aug 23, 2019
1 parent bfdc7b4 commit 42c6f226fd135951789fdc360e95792f2502f45c
Show file tree
Hide file tree
Showing 5 changed files with 475 additions and 0 deletions.
BIN +38.8 KB executer
Binary file not shown.
149 header.h
@@ -0,0 +1,149 @@
#include <iostream>
#include <array>
#include <string>
#include "libsqlite.hpp"

using namespace std;

void SearchLect(int module_code){

try
{
sqlite::sqlite db( "uni_TimeTable.db" ); //open database
auto curs= db.get_statement(); //create cursor
curs->set_sql( "select lecturers.Name from lecturers,lecturer_module where lecturer_module.lecturer=lecturers.lect_ID and module=(?);" );

curs->prepare();
curs->bind( 1, module_code );
while( curs->step()){

cout <<" "<< curs->get_text(0) << " " <<endl;


}

}

catch( sqlite::exception e )

{
cerr << e.what() << endl;


}


}


int NewLecturers(int id, string name, int number){
try
{
sqlite::sqlite db( "uni_TimeTable.db" ); //open database
auto curs= db.get_statement();//create cursor
curs->set_sql( "INSERT INTO Lecturers ( Lect_ID, name, number) "

"VALUES (?, ?, ?);" );

curs->prepare();
curs->bind( 1, id );
curs->bind( 2, name );
curs->bind( 3, number );
curs->step();

}

catch( sqlite::exception e )

{
cerr << e.what() << endl;
return 1;

}

}
int NewStudents(int id, string Name, int number){
try
{
sqlite::sqlite db( "uni_TimeTable.db" ); //open database
auto curs = db.get_statement();//create cursor
curs->set_sql( "INSERT INTO Students ( ID, name, number) "

"VALUES (?, ?, ?);" );// insert into DB

curs->prepare();
curs->bind( 1, id );
curs->bind( 2, Name );
curs->bind( 3,number );
curs->step();

}

catch( sqlite::exception e )

{
cerr << e.what() << endl;
return 1;

}

}

int displayLecturers(){

try

{

sqlite::sqlite db( "uni_TimeTable.db" ); // open database

auto curs = db.get_statement();

curs->set_sql( "SELECT * FROM Lecturers" );// set query
curs->prepare();

while( curs->step()){

cout <<" "<< curs->get_int(0) << " " << curs->get_text(1) <<endl;
}

}

catch( sqlite::exception e ){

cerr << e.what() << endl;

return 1;

}

}
int displayStudents(){

try

{
sqlite::sqlite db( "uni_TimeTable.db" ); // open database

auto curs = db.get_statement();
curs->set_sql( "SELECT * FROM Students" );// set query
curs->prepare();

while( curs->step()){

cout <<" "<< curs->get_int(0) << " " << curs->get_text(1) << " " << curs->get_int(2)<<endl;


}

}

catch( sqlite::exception e ){

cerr << e.what() << endl;

return 1;

}

}

0 comments on commit 42c6f22

Please sign in to comment.