Ejemplo n.º 1
0
def enregistrement(classe, table, list, thype, coef, tri, num):
    conn, cursor = connect_db()
    for k in range(len(classe.eleves)):
        data = table.item(k, 2)
        enregistrer(data, classe.eleves[k], cursor, list[k], thype, coef, tri,
                    num)
    close_db(conn)
Ejemplo n.º 2
0
 def create(cls, etudiant: tuple):
     conn, cursor = fonctions_db.connect_db()
     fonctions_db.execute_query(
         conn, cursor,
         f"""insert into etudiant (Matricule, Nom, Prenoms, Sexe, Code_Cl) VALUES (%s ,%s, %s, %s, %s)""",
         etudiant)
     return cls(conn.insert_id(), cursor=cursor)
Ejemplo n.º 3
0
def supprimer_note(c, tr, classe):
    conn, cursor = connect_db()
    note = classe.eleves[0].notes[tr][c - 2]
    cursor.execute(
        """DELETE FROM notes WHERE id_classe="{}" AND numero="{}" AND type="{}" AND trimestre="{}"  """
        .format(note.id_classe, note.numero, note.type, note.trimestre))
    close_db(conn)
Ejemplo n.º 4
0
 def create(cls, classe: tuple):
     conn, cursor = fonctions_db.connect_db()
     fonctions_db.execute_query(
         conn, cursor,
         f"""insert into classe (Code_Cl, Intitule, Effectif) VALUES (%s ,%s, %s)""",
         classe)
     return cls(conn.insert_id(), cursor=cursor)
Ejemplo n.º 5
0
 def charge_eleves(self):
     conn, cursor = connect_db()
     cursor.execute(
         """SELECT * FROM eleve WHERE id_classe='{}' ORDER BY nom,prenom,id"""
         .format(self.id))
     id_eleve, list_note = cursor.fetchall(), []
     cursor.execute(
         """SELECT * FROM notes WHERE id_classe='{}' AND type=' IN' ORDER BY numero"""
         .format(self.id))
     aux2 = cursor.fetchall()
     list_note += aux2
     cursor.execute(
         """SELECT * FROM notes WHERE id_classe='{}' AND type!=' IN' ORDER BY type,numero"""
         .format(self.id))
     aux2 = cursor.fetchall()
     list_note += aux2
     self.eleves = [
         Eleve(aux[0],
               cursor=cursor,
               stop=0,
               eleve=aux,
               id_note=[nd for nd in list_note if nd[1] == aux[0]])
         for aux in id_eleve
     ]
     if len(id_eleve) > 0:
         for i in range(3):
             if len(self.eleves[0].notes[i]) > 0:
                 self.list_rang[i] = self.rang(i)
     close_db(conn)
Ejemplo n.º 6
0
 def create(cls, livre: tuple):
     conn, cursor = fonctions_db.connect_db()
     fonctions_db.execute_query(
         conn, cursor,
         f"""insert into livre (Code_Liv, Titre, Auteur, Genre, Prix) VALUES (%s ,%s, %s, %s, %s)""",
         livre)
     return cls(conn.insert_id(), cursor=cursor)
Ejemplo n.º 7
0
 def create(cls, emprunt: tuple):
     conn, cursor = fonctions_db.connect_db()
     fonctions_db.execute_query(
         conn, cursor,
         f"""insert into emprunt (Matricule, Code_Liv, Sortie, Retour) VALUES (%s, %s, %s, %s)""",
         emprunt, close)
     return cls(conn.insert_id(), cursor=cursor)
Ejemplo n.º 8
0
 def __init__(self, code_cl, cursor=None, stop=1, classe=None, eleve=None):
     if cursor == None:
         conn, cursor = fonctions_db.connect_db()
     if classe == None:
         classe = fonctions_db.execute_query(
             conn if conn else None,
             cursor,
             f"""SELECT * FROM classe WHERE Code_Cl = '{code_cl}' """,
             is_result=True)
     self.Code_Cl, self.Intitule, self.Effectif = classe[0], classe[
         1], classe[2]
Ejemplo n.º 9
0
 def __init__(self, code_liv, cursor=None, stop=1, livre=None):
     if cursor == None:
         conn, cursor = fonctions_db.connect_db()
     if livre == None:
         livre = fonctions_db.execute_query(
             conn if conn else None,
             cursor,
             f"""SELECT * FROM livre WHERE Code_Liv = '{code_liv}' """,
             is_result=True)
     self.Code_Liv, self.Titre, self.Auteur, self.Genre, self.Prix = livre[
         0], livre[1], livre[2], livre[3], livre[4]
Ejemplo n.º 10
0
 def __init__(self, id_emprunt, cursor=None, stop=1, emprunt=None):
     if cursor == None:
         conn, cursor = fonctions_db.connect_db()
     if emprunt == None:
         emprunt = fonctions_db.execute_query(
             conn if conn else None,
             cursor,
             f"""SELECT * FROM emprunt WHERE id = '{id_emprunt}' """,
             is_result=True)
     self.id, self.Matricule, self.Code_Liv, self.Sortie, self.Retour = emprunt[
         0], emprunt[1], emprunt[2], emprunt[3], emprunt[4]
Ejemplo n.º 11
0
 def __init__(self):
     conn, cursor = connect_db()
     cursor.execute("""SELECT nom,prenom,sexe,passe FROM users""")
     param_us = cursor.fetchone()
     self.nom, self.prenom, self.sexe, self.mot_passe = param_us[
         0], param_us[1], param_us[2], param_us[3]
     cursor.execute(
         """SELECT * FROM etablissement ORDER BY nom,annee DESC""")
     id_etablissement = cursor.fetchall()
     self.etablissements = [
         Etablissement(aux[0], cursor=cursor, stop=0, etablissement=aux)
         for aux in id_etablissement
     ]
     close_db(conn)
Ejemplo n.º 12
0
def direct(sheet, empl, id_classe):
    conn, cursor = connect_db()
    for i in range(empl[0] + 1, sheet.nrows):
        nom, prenom = str(sheet.cell_value(i, empl[1])), str(
            sheet.cell_value(i, empl[1] + 1))
        nom, prenom = nom.replace(" ", "").capitalize(), prenom.split(" ")
        for j in range(len(prenom)):
            prenom[j] = prenom[j].capitalize()
        prenom = " ".join(prenom)
        if nom != "" and prenom != "":
            cursor.execute(
                """INSERT INTO eleve(id_classe,nom,prenom) VALUES('{}',"{}","{}")"""
                .format(id_classe, nom, prenom))
        else:
            break
    close_db(conn)
Ejemplo n.º 13
0
 def __init__(self,
              id_classe,
              cursor=None,
              stop=1,
              classe=None,
              eleve=None):
     if cursor == None:
         conn, cursor = connect_db()
     if classe == None:
         cursor.execute(
             """SELECT * FROM classe WHERE id = '{}' """.format(id_classe))
         classe = cursor.fetchone()
     self.id, self.id_etablissement, self.niveau, self.serie, self.numero = classe[
         0], classe[1], classe[2], classe[3], classe[4]
     self.eleves, self.list_rang = [], [[], [], []]
     if eleve == None:
         self.charge_eleves()
     if stop == 1:
         close_db(conn)
Ejemplo n.º 14
0
 def __init__(
     self,
     matricule,
     cursor=None,
     stop=1,
     etudiant=None,
 ):
     if cursor is None:
         conn, cursor = fonctions_db.connect_db()
     if etudiant == None:
         etudiant = fonctions_db.execute_query(
             conn if conn else None,
             cursor,
             f"""SELECT * FROM etudiant WHERE Matricule = '{matricule}' """,
             is_result=True)
     self.Matricule, self.Nom, self.Prenoms, self.Sexe, self.classe = etudiant[
         0], etudiant[1], etudiant[2], etudiant[3], classes.classe.Classe(
             code_cl=etudiant[4])
     if stop == 1:
         fonctions_db.close_db(conn)
Ejemplo n.º 15
0
 def __init__(self,
              id_eleve,
              cursor=None,
              stop=1,
              eleve=None,
              id_note=None):
     if cursor == None:
         conn, cursor = connect_db()
     if eleve == None:
         cursor.execute(
             """SELECT * FROM eleve WHERE id = '{}'""".format(id_eleve))
         eleve = cursor.fetchone()
     self.id, self.id_classe, self.nom, self.prenom = eleve[0], eleve[
         1], eleve[2], eleve[3]
     if id_note == None:
         id_note = []
         cursor.execute(
             """SELECT * FROM notes WHERE id_eleve='{}' AND type=' IN' ORDER BY numero"""
             .format(self.id))
         aux = cursor.fetchall()
         id_note += aux
         cursor.execute(
             """SELECT * FROM notes WHERE id_eleve='{}' AND type!=' IN' ORDER BY type,numero"""
             .format(self.id))
         aux = cursor.fetchall()
         id_note += aux
     self.notes = [[
         Note(aux[0], cursor=cursor, stop=0, note=aux) for aux in id_note
         if aux[5] == n
     ] for n in range(1, 4)]
     if stop == 1:
         close_db(conn)
     self.moyenne, self.rang = [None, None, None], [None, None, None]
     for i in range(len(self.notes)):
         if len(self.notes[i]) > 0:
             self.moyenne[i] = (
                 sum(n.note for n in self.notes[i] if n.note != None) /
                 sum(n.coefficient for n in self.notes[i]))
         else:
             self.moyenne[i] = 0
Ejemplo n.º 16
0
 def __init__(self, id_note, cursor=None, stop=1, note=None):
     if cursor == None:
         conn, cursor = connect_db()
     if note == None:
         cursor.execute(
             """SELECT * FROM notes WHERE id = '{}'""".format(id_note))
         note = cursor.fetchone()
     if stop == 1:
         close_db(conn)
     self.id, self.id_eleve, self.type, self.coefficient, self.note, self.trimestre, self.numero, self.date, self.id_classe = note[
                                                                                                                  0], \
                                                                                                              note[
                                                                                                                  1], \
                                                                                                              note[
                                                                                                                  2], \
                                                                                                              note[
                                                                                                                  3], \
                                                                                                              note[
                                                                                                                  4], \
                                                                                                              note[
                                                                                                                  5], \
                                                                                                              note[
                                                                                                                  6], \
                                                                                                              note[7], note[8]
Ejemplo n.º 17
0
 def __init__(self,
              id_etablissement,
              cursor=None,
              stop=1,
              etablissement=None):
     if cursor == None:
         conn, cursor = connect_db()
     if etablissement == None:
         cursor.execute(
             """SELECT * FROM etablissement WHERE id = '{}' """.format(
                 id_etablissement))
         etablissement = cursor.fetchone()
     self.id, self.nom, self.annee = etablissement[0], etablissement[
         1], etablissement[2]
     cursor.execute(
         """SELECT * FROM classe WHERE id_etablissement='{}' ORDER BY niveau DESC,serie,numero"""
         .format(self.id))
     id_classe = cursor.fetchall()
     self.classes = [
         Classe(aux[0], cursor=cursor, stop=0, classe=aux, eleve="yes")
         for aux in id_classe
     ]
     if stop == 1:
         close_db(conn)
Ejemplo n.º 18
0
import fonctions_db

conn, cursor = fonctions_db.connect_db()
fonctions_db.create_db(conn, cursor)