import psycopg2

def DB_students(DB_NAME, DB_USER, DB_PASS, DB_HOST):

    try:
        conn = psycopg2.connect(dbname=DB_NAME, user=DB_USER, password=DB_PASS, host=DB_HOST)
    except:
        print("I am unable to connect to the database")

    cur = conn.cursor()

    print("Insert students into table...")
    cur.execute("insert into etudiants values(051135593,'Marie Blanche','Anglais','Master 1',21);")
    cur.execute("insert into etudiants values(060839453,'Charles Harry','Architecture','Master 1',22);")
    cur.execute("insert into etudiants values(099354543,'Susanne Martin','Droit','Licence 3',20);")
    cur.execute("insert into etudiants values(112348546,'Joseph Thomas','Informatique','Licence 2',19);")
    cur.execute("insert into etudiants values(115987938,'Christophe Cordier','Informatique','Licence 3',20);")
    cur.execute("insert into etudiants values(132977562,'Angela Martinet','Histoire','Master 1',20);")
    cur.execute("insert into etudiants values(269734834,'Thomas Robet','Psychologie','Licence 2',18);")
    cur.execute("insert into etudiants values(280158572,'Margarethe Cousin','Medecine Veterinaire','Licence 1',18);")
    cur.execute("insert into etudiants values(301221823,'Jean Robinet','Psychologie','Licence 3',20);")
    cur.execute("insert into etudiants values(318548912,'Dorothee Lechemin','Finance','Licence 1',18);")
    cur.execute("insert into etudiants values(320874981,'Daniel Lemaire','Electronique','Licence 1',17);")
    cur.execute("insert into etudiants values(322654189,'Lisa Marcheur','Informatique','Licence 2',17);")
    cur.execute("insert into etudiants values(348121549,'Paul Cheminot','Informatique','Licence 3',18);")
    cur.execute("insert into etudiants values(351565322,'Nancy Alain','Comptabilite','Licence 3',19);")
    cur.execute("insert into etudiants values(451519864,'Marc Jeune','Finance','Licence 1',18);")
    cur.execute("insert into etudiants values(455798411,'Louis Fernand','Electronique','Licence 1',17);")
    cur.execute("insert into etudiants values(462156489,'Damien Leroi','Mecanique','Licence 2',19);")
    cur.execute("insert into etudiants values(550156548,'Georges Watteau','Pedagogique','Master 1',21);")
    cur.execute("insert into etudiants values(552455318,'Anna Lopet','MIAGE','Master 1',19);")
    cur.execute("insert into etudiants values(556784565,'Morgan Monl','Genie Civil','Master 1',21);")
    cur.execute("insert into etudiants values(567354612,'Seraphine El Smail','MIAGE','Licence 1',18);")
    cur.execute("insert into etudiants values(573284895,'Stephane Vert','Kinesitherapie','Licence 2',19);")
    cur.execute("insert into etudiants values(574489456,'Betty Alambert','Economie','Licence 3',20);")
    cur.execute("insert into etudiants values(578875478,'Eduouard Blanchet','Medecine Veterinaire','Master 1',21);")

    print("Insert professors into table...")
    cur.execute("insert into profs values(142519864,'I. Boulala',20);")
    cur.execute("insert into profs values(242518965,'Anael Klein',68);")
    cur.execute("insert into profs values(141582651,'Joris Robillard',20);")
    cur.execute("insert into profs values(011564812,'Laura Giacco',68);")
    cur.execute("insert into profs values(254099823,'Patricia Jones',68);")
    cur.execute("insert into profs values(356187925,'Victor Goron',12);")
    cur.execute("insert into profs values(489456522,'Linda Mariencourt',20);")
    cur.execute("insert into profs values(287321212,'Valentin Owczarek',12);")
    cur.execute("insert into profs values(248965255,'Brahim Akouz',12);")
    cur.execute("insert into profs values(159542516,'Astelia Massamba',33);")
    cur.execute("insert into profs values(090873519,'Hugo Ermenidis',11);")
    cur.execute("insert into profs values(486512566,'Boubacar Diallo',20);")
    cur.execute("insert into profs values(619023588,'Justin Dutoit',11);")
    cur.execute("insert into profs values(489221823,'Nadir Trabelsi',33);")
    cur.execute("insert into profs values(548977562,'Ulysses Boulala',20);")

    print("Insert cours into table...")
    cur.execute("insert into cours values(1,'Structures de Donnees','LuMeVe 10','R128',489456522);")
    cur.execute("insert into cours values(2,'Systemes de Bases de Donnees','LuMeVe 12:30-1:45','1320 DCL',142519864);")
    cur.execute("insert into cours values(3,'Conception de Systemes d Exploitation','MaJeu 12-1:20','20 AVW',489456522 );")
    cur.execute("insert into cours values(4,'Psychologie',null,'null',619023588);")
    cur.execute("insert into cours values(5,'Archeologie des Incas','LuMeVe 3-4:15','R128',248965255);")
    cur.execute("insert into cours values(6,'Analyse d Accidents Aeronautiques','MaJeu 1-2:50','Q3',011564812);")
    cur.execute("insert into cours values(7,'Gestion de la qualite d air','MaJeu 10:30-11:45','R15',011564812);")
    cur.execute("insert into cours values(8,'Introduction au Latin','LuMeVe 3-4:15','R12',248965255);")
    cur.execute("insert into cours values(9,'Partis politiques francais','MaJeu 2-3:15','20 AVW',619023588);")
    cur.execute("insert into cours values(10,'Cognition Sociale','Ma 6:30-8:40','R15',159542516);")
    cur.execute("insert into cours values(11,'Perception','LuMaMeJeu 3','Q3',489221823);")
    cur.execute("insert into cours values(12,'Analyse multivariee','MaJeu 2-3:15','R15',090873519);")
    cur.execute("insert into cours values(13,'Droit des brevets','Ve 1-2:50','R128',090873519);")
    cur.execute("insert into cours values(14,'Economie Urbaine','LuMeVe 11','20 AVW',489221823);")
    cur.execute("insert into cours values(15,'Chimie organique','MaJeu 12:30-1:45','R12',489221823);")
    cur.execute("insert into cours values(16,'Marketing','LuMe 10-11:15','1320 DCL',489221823);")
    cur.execute("insert into cours values(17,'Art italien de la renaissance','Lu 4','R15',489221823);")
    cur.execute("insert into cours values(18,'Mecanique des orbites','LuMeVe 8','1320 DCL',011564812);")
    cur.execute("insert into cours values(19,'Elevage bovin','MaJeu 12:30-1:45','R128',356187925);")
    cur.execute("insert into cours values(20,'Reseaux de communication','MaMe 9:30-10:45','20 AVW',141582651);")
    cur.execute("Insert into cours values(21,'Electronique optique','MaJeu 12:30-1:45','R15',254099823);")
    cur.execute("insert into cours values(22,'Intelligence artificielle',null,'UP328',null);")
    cur.execute("insert into cours values(23,'Introduction a l Algebre Lineaire','MaJeu 8-9:30','R128',489221823);")

    print("Insert participation into table...")
    cur.execute("insert into participer values(112348546,2);")
    cur.execute("insert into participer values(115987938,2);")
    cur.execute("insert into participer values(348121549,2);")
    cur.execute("insert into participer values(322654189,2);")
    cur.execute("insert into participer values(552455318,2);")
    cur.execute("insert into participer values(455798411,3);")
    cur.execute("insert into participer values(552455318,3);")
    cur.execute("insert into participer values(567354612,3);")
    cur.execute("insert into participer values(112348546,3);")
    cur.execute("insert into participer values(115987938,3);")
    cur.execute("insert into participer values(322654189,3);")
    cur.execute("insert into participer values(567354612,1);")
    cur.execute("insert into participer values(552455318,20);")
    cur.execute("insert into participer values(455798411,21);")
    cur.execute("insert into participer values(455798411,15);")
    cur.execute("insert into participer values(301221823,11);")
    cur.execute("insert into participer values(301221823,10);")
    cur.execute("insert into participer values(301221823,1);")
    cur.execute("insert into participer values(556784565,7);")
    cur.execute("insert into participer values(099354543,7);")
    cur.execute("insert into participer values(322654189,13);")
    cur.execute("insert into participer values(574489456,14);")

    print("\n----commit in the DB----\n")
    conn.commit()

    cur.close()

    conn.close()
