Esempio n. 1
0
class MenuRegistro:
    def __init__(self, conexion, cursor):
        self.registro = Registro(conexion, cursor)
        while True:
            print("1) Agregar Registro")
            print("2) Buscar Registros")
            print("0) Salir")
            op = input()
            
            if op=="1":
                self.agregar()
            elif op=="2":
                self.buscar()
            elif op=="0":
                break
                
                
    def agregar(self):
        dia = input("Dia: ")
        mes = input("Mes: ")
        year = input("Año: ")
        fecha = date(int(year), int(mes), int(dia))
        ph = input("pH: ")
        luz = input("Luz: ")
        humedad = input("Humedad: ")
        c02 = input("co2: ")
        id_planta = input("ID Planta: ")
        self.registro.crear(fecha, ph, luz, humedad, c02, id_planta)
        
    def buscar(self):
        id_planta = input("ID Planta: ")
        resultados=self.registro.recuperar(id_planta)
        
        for p in resultados:
            print("{0:2} {1:5} {2:5} {3:5} {4:5} {5:5} {6:5}".format(p[0], str(p[1]), p[2], p[3], p[4], p[5], p[6]))
Esempio n. 2
0
class MenuRegistro:
    def __init__(self, conexion, cursor):
        self.registro = Registro(conexion, cursor)
        while(True):
            print("1) Agregar Registro")
            print("2) Mostrar Registro")
            print("0) Salir")
            op = input("Opcion: ")

            if op == "1":
                self.agregar()
            elif op == "2":
                self.mostrar()
            elif op == "0":
                break

    def agregar(self):
        dia = input("Dia: ")
        mes = input("Mes: ")
        anio = input("Año: ")
        fecha = date(int(anio), int(mes), int(dia))
        ph = float(input("PH: "))
        luz= float(input("Luz: "))
        humedad = float(input("Humedad: "))
        co2 = float(input("CO2: "))
        planta_id = input("Planta: ")
        self.registro.crear(fecha, ph, luz, humedad, co2, planta_id)

    def mostrar(self):
        try:
            temp = ["No","Fecha","PH","Luz","Humedad","CO2"]
            ID = input("Planta: ")
            resultados = self.registro.recuperar(ID)
            print("| {0:2} | {1:10} | {2:4} | {3:4} | {4:7} | {5:4} |".format(temp[0], temp[1], temp[2], temp[3], temp[4], temp[5]))
            for n in resultados:
                print("| {0:2} | {1:10} | {2:4} | {3:4} | {4:4} | {5:4} |".format(n[0], str(n[1]), n[2], n[3], n[4], n[5]))
        except:
            print("No se ha encontrado el registro")