Exemple #1
0
 def eliminar_alumno_id(self, id):
     try:
         conn = Connection()
         query = f'''
             DELETE FROM alumno WHERE id = {id};
         '''
         conn.execute_query(query)
         conn.commit()
         print(f'Se elimino el alumno con ID {id}')
     except Exception as e:
         print(f'{str(e)}')
Exemple #2
0
    def update_curso(self, id):
        try:
            conn = Connection()
            query = f'''
                UPDATE curso SET nombre = '{self.nombre}' WHERE id = {id};
            '''
            conn.execute_query(query)
            conn.commit()

            print(f'Se actualizo el curso con el ID {id} por -> {self.nombre}')
        except Exception as e:
            print(f'{str(e)}')
Exemple #3
0
 def registro_alumno_curso(self, idcursoprofesor, idalumnogrado, nota=''):
     try:
         conn = Connection()
         query = f'''
             INSERT INTO registro_alumno_curso(idcursoprofesor, idalumnogrado)
                 VALUES({idcursoprofesor}, {idalumnogrado});
         '''
         conn.execute_query(query)
     except Exception as e:
         print(f'Error -> {str(e)}')
     finally:
         conn.close_connection()
Exemple #4
0
 def aperturar_alumno_grado(self, id_apertura, id_alumno):
     try:
         conn = Connection()
         query = f'''
             INSERT INTO apertura_alumno_grado(idapertura, idalumno)
                 VALUES({id_apertura}, {id_alumno});
         '''
         conn.execute_query(query)
     except Exception as e:
         print(f'Error -> {str(e)}')
     finally:
         conn.close_connection()
Exemple #5
0
 def update_alumno(self, id):
     try:
         conn = Connection()
         query = f'''
             UPDATE alumno SET nombres = '{self.nombres}', apellido_pat='{self.apellido_pat}', apellido_mat='{self.apellido_mat}' WHERE id = {id};
         '''
         conn.execute_query(query)
         conn.commit()
         print(
             f'Se actualizo el alumno con el ID {id} por -> {self.nombres}')
     except Exception as e:
         print(f'{str(e)}')
Exemple #6
0
    def update_neduc(self, id):
        try:
            conn = Connection()
            query = f'''
                UPDATE mobile SET model = '{self.descrip_ned}' WHERE id = {id};
            '''
            conn.execute_query(query)
            conn.commit()

            print(f'Se actualizo el nievel educativo con el ID {id} por -> {self.descrip_ned}')
        except Exception as e:
            print(f'{str(e)}')
Exemple #7
0
    def delete_anio_escolar(self, id):
        try:
            conn = Connection()
            query = f'''
                DELETE FROM anio_escolar WHERE id = {id};
            '''
            conn.execute_query(query)
            conn.commit()

            print(f'Se elimino el año con ID {id}')
        except Exception as e:
            print(f'{str(e)}')
Exemple #8
0
 def guardar_alumno(self):
     try:
         #[model, price] => model,price
         conn = Connection()
         query = f'''
             INSERT INTO alumno (nombres,apellido_pat,apellido_mat) 
             VALUES('{self.nombres}','{self.apellido_pat}','{self.apellido_mat}');
         '''
         conn.execute_query(query)
         conn.commit()
         print(f'Se agrego un alumno -> {self.nombres}')
     except Exception as e:
         print(f'{str(e)}')
Exemple #9
0
 def create_table(self):
     try:
         conn = Connection()
         query = '''
             CREATE TABLE IF NOT EXISTS nivel_educativo(
                 id_ned  SERIAL  PRIMARY KEY NOT NULL,
                 descrip_ned varchar(50) NOT NULL
             );
         '''
         conn.execute_query(query)
         conn.commit()
     except Exception as e:
         raise print(e)
Exemple #10
0
 def insert_neduc(self):
     try:
         #[model, price] => model,price
         conn = Connection()
         query = f'''
             INSERT INTO nivel_educativo (descrip_ned) 
             VALUES('{self.descrip_ned}')
         '''
         conn.execute_query(query)
         conn.commit()
         print(f'Se agrego un nivel educativo -> {self.descrip_ned}')
     except Exception as e:
         print(f'{str(e)}')
Exemple #11
0
 def guardar_anio_escolar(self):
     try:
         #[model, price] => model,price
         conn = Connection()
         query = f'''
             INSERT INTO anio_escolar (anio,descripcion) 
             VALUES('{self.anio}','{self.descripcion}');
         '''
         conn.execute_query(query)
         conn.commit()
         print(f'Se agrego un año escolcar -> {self.anio}')
     except Exception as e:
         print(f'{str(e)}')
Exemple #12
0
 def create_table(self):
     try:
         conn = Connection()
         query = '''
             CREATE TABLE IF NOT EXISTS alumno(
                 id_alumno  SERIAL  PRIMARY KEY NOT NULL,
                 nombre_alumno varchar(50) NOT NULL
             );
         '''
         conn.execute_query(query)
         conn.commit()
     except Exception as e:
         raise print(e)
Exemple #13
0
 def insert_curso(self):
     try:
         #[model, price] => model,price
         conn = Connection()
         query = f'''
             INSERT INTO curso (nombre) 
             VALUES('{self.nombre}')
         '''
         conn.execute_query(query)
         conn.commit()
         print(f'Se agrego un curso -> {self.nombre}')
     except Exception as e:
         print(f'{str(e)}')
Exemple #14
0
    def update_anio_escolar(self, id):
        try:
            conn = Connection()
            query = f'''
                UPDATE anio_escolcar SET anio = '{self.anio}', descripcion='{self.descripcion}' WHERE id = {id};
            '''
            conn.execute_query(query)
            conn.commit()

            print(
                f'Se actualizo el año escolar con el ID {id} por -> {self.anio}'
            )
        except Exception as e:
            print(f'{str(e)}')
Exemple #15
0
 def fetchmany_alumno(self):
     try:
         conn = Connection()
         query = '''
             SELECT * FROM alumno;
         '''
         cursor = conn.execute_query(query)
         rows = cursor.fetchmany(2)
         print('First -> 2 rows')
         for row in rows:
             print(f'id = {row[0]}')
             print(f'nombres = {row[1]}')
             print(f'apellido_pat = {row[2]}')
             print(f'apellido_mat = {row[3]}')
             print('=====================')
         rows = cursor.fetchmany(3)
         print('Seconds -> 2 rows')
         for row in rows:
             print(f'id = {row[0]}')
             print(f'nombres = {row[1]}')
             print(f'apellido_pat = {row[2]}')
             print(f'apellido_mat = {row[3]}')
             print('=====================')
     except Exception as e:
         print(f'{str(e)}')
Exemple #16
0
    def aperturar_anio_escolar(self, idanio, idgrado):
        try:
            conn = Connection()
            query = f'''
                INSERT INTO apertura_alumno_grado(idanio, idgrado)
                    VALUES({idanio}, {idgrado});
            '''
            conn.execute_query(query)
        except Exception as e:
            print(f'Error -> {str(e)}')
        finally:
            conn.close_connection()


#A=anio_escolar('2020','Dos mil veinte')
#A.guardar_anio_escolar()
#A.fetchone_alumno()
#A.fetchall_anio_escolar()
Exemple #17
0
    def registro_nota_periodo_alumno(self,
                                     idalumnocurso,
                                     idperiodoeval,
                                     nota=''):
        try:
            conn = Connection()
            query = f'''
                INSERT INTO registro_nota_periodo_alumno(idalumnocurso, idperiodoeval,nota)
                    VALUES({idalumnocurso}, {idperiodoeval},{nota});
            '''
            conn.execute_query(query)
        except Exception as e:
            print(f'Error -> {str(e)}')
        finally:
            conn.close_connection()


#A=Alumno('','Carmen','Laos','Rios')
#A.guardar_alumno()
#A.fetchone_alumno()
#A.fetchall_alumno()
Exemple #18
0
 def consultar_alumno_todos(self):
     try:
         conn = Connection()
         query = f'''
             SELECT id, nombres, apellido_pat, apellido_mat
                 FROM alumno;
         '''
         cursor = conn.execute_query(query)
         self.lista_alumno = cursor.fetchall()
     except Exception as e:
         print(f'Error -> {str(e)}')
     finally:
         conn.close_connection()
Exemple #19
0
 def fetchone_neduc(self):
     try:
         conn = Connection()
         query = '''
             SELECT * FROM nivel_educativo;
         '''
         cursor = conn.execute_query(query)
         row = cursor.fetchone()
         print(f'id_ned = {row[0]}')
         print(f'descrip_ned = {row[1]}')
         print('=====================')
     except Exception as e:
         print(f'{str(e)}')
Exemple #20
0
 def fetchone_curso(self):
     try:
         conn = Connection()
         query = '''
             SELECT * FROM curso;
         '''
         cursor = conn.execute_query(query)
         row = cursor.fetchone()
         print(f'id = {row[0]}')
         print(f'nombre = {row[1]}')
         print('=====================')
     except Exception as e:
         print(f'{str(e)}')
Exemple #21
0
 def consultar_anio_todos(self):
     try:
         conn = Connection()
         query = f'''
             SELECT id, anio, descripcion
                 FROM anio_escolar;
         '''
         cursor = conn.execute_query(query)
         self.lista_anio = cursor.fetchall()
     except Exception as e:
         print(f'Error -> {str(e)}')
     finally:
         conn.close_connection()
Exemple #22
0
 def fetchone_anio_escolar(self):
     try:
         conn = Connection()
         query = '''
             SELECT * FROM anio_escolar;
         '''
         cursor = conn.execute_query(query)
         row = cursor.fetchone()
         print(f'id = {row[0]}')
         print(f'anio = {row[1]}')
         print(f'descripcion = {row[2]}')
         print('=====================')
     except Exception as e:
         print(f'{str(e)}')
Exemple #23
0
 def fetchall_curso(self):
     try:
         conn = Connection()
         query = '''
             SELECT * FROM curso;
         '''
         cursor = conn.execute_query(query)
         rows = cursor.fetchall()
         for row in rows:
             print(f'id_curso = {row[0]}')
             print(f'nombre_curso = {row[1]}')
             print('=====================')
     except Exception as e:
         print(f'{str(e)}')
Exemple #24
0
 def fetchone_alumno(self):
     try:
         conn = Connection()
         query = '''
             SELECT * FROM alumno;
         '''
         cursor = conn.execute_query(query)
         row = cursor.fetchone()
         print(f'id = {row[0]}')
         print(f'nombres = {row[1]}')
         print(f'apellido_pat = {row[2]}')
         print(f'apellido_mat = {row[3]}')
         print('=====================')
     except Exception as e:
         print(f'{str(e)}')
Exemple #25
0
 def consultar_anio_id(self):
     try:
         conn = Connection()
         query = f'''
             SELECT id, anio, descripcion
             FROM anio_escolar
             WHERE id = {self.id};
         '''
         cursor = conn.execute_query(query)
         self.lista_anio = cursor.fetchall()
         for anio in self.lista_anio:
             self.id = anio[0]
             self.anio = anio[1]
             self.descripcion = anio[2]
     except Exception as e:
         print(f'Error -> {str(e)}')
     finally:
         conn.close_connection()
Exemple #26
0
 def consultar_alumno_id(self):
     try:
         conn = Connection()
         query = f'''
             SELECT id, nombres, apellido_pat, apellido_mat
             FROM alumno
             WHERE id = {self.id};
         '''
         cursor = conn.execute_query(query)
         self.lista_alumno = cursor.fetchall()
         for alumno in self.lista_alumno:
             self.id = alumno[0]
             self.nombres = alumno[1]
             self.apellido_pat = alumno[2]
             self.apellido_mat = alumno[3]
     except Exception as e:
         print(f'Error -> {str(e)}')
     finally:
         conn.close_connection()
Exemple #27
0
 def consultar_alumno_grado(self, idapertura):
     try:
         conn = Connection()
         query = f'''
             SELECT A.id, A.nombres, A.apellido_pat, A.apellido_mat
             FROM alumno A
             Inner join apertura_alumno_grado B on A.id = B.idalumno                
             WHERE B.idapertura={idapertura};
         '''
         cursor = conn.execute_query(query)
         self.lista_alumno = cursor.fetchall()
         for alumno in self.lista_alumno:
             self.id = alumno[0]
             self.nombres = alumno[1]
             self.apellido_pat = alumno[2]
             self.apellido_mat = alumno[3]
     except Exception as e:
         print(f'Error -> {str(e)}')
     finally:
         conn.close_connection()
Exemple #28
0
 def fetchmany_curso(self):
     try:
         conn = Connection()
         query = '''
             SELECT * FROM curso;
         '''
         cursor = conn.execute_query(query)
         rows = cursor.fetchmany(2)
         print('First -> 2 rows')
         for row in rows:
             print(f'id_curso = {row[0]}')
             print(f'nombre_curso = {row[1]}')
             print('=====================')
         rows = cursor.fetchmany(3)
         print('Seconds -> 2 rows')
         for row in rows:
             print(f'id_curso = {row[0]}')
             print(f'nombre_curso = {row[1]}')
             print('=====================')
     except Exception as e:
         print(f'{str(e)}')
Exemple #29
0
 def fetchmany_neduc(self):
     try:
         conn = Connection()
         query = '''
             SELECT * FROM nivel_educativo;
         '''
         cursor = conn.execute_query(query)
         rows = cursor.fetchmany(2)
         print('First -> 2 rows')
         for row in rows:
             print(f'id_ned = {row[0]}')
             print(f'descrip_ned = {row[1]}')
             print('=====================')
         rows = cursor.fetchmany(3)
         print('Seconds -> 2 rows')
         for row in rows:
             print(f'id_ned = {row[0]}')
             print(f'descrip_ned = {row[1]}')
             print('=====================')
     except Exception as e:
         print(f'{str(e)}')
Exemple #30
0
 def consultar_alumno_nombre(self, nombre, anio):
     try:
         conn = Connection()
         query = f'''
             SELECT A.id, A.nombres, A.apellido_pat, A.apellido_mat
             FROM alumno A
             Inner join apertura_alumno_grado B on A.id = B.idalumno
             Inner join apertura_escolar C on B.idapertura=C.id  
             Inner join anio_escolar D on C.idanio=D.id             
             WHERE D.anio='{anio}' and A.nombres like '%{nombre}%';
         '''
         cursor = conn.execute_query(query)
         self.lista_alumno = cursor.fetchall()
         for alumno in self.lista_alumno:
             self.id = alumno[0]
             self.nombres = alumno[1]
             self.apellido_pat = alumno[2]
             self.apellido_mat = alumno[3]
     except Exception as e:
         print(f'Error -> {str(e)}')
     finally:
         conn.close_connection()