Hello, I hope so. When I execute in Python the part of the menu runs fine but when I would have to show the data of the person that is in the table, [] appears.
Selecciona una opción para Buscar Paciente
1 - Por DNI
2 - Por nombre
3 - Por edad
9 - salir
inserta un numero valor >> 1
Ingrese DNI: 40396902
[]
^
From Patients BBDD.py I call this function that is in Patients_f.py
Lista_Paciente(miPuntero)
Functions of Patients_f.py
def menuListap():
import os
os.system('cls')
print ("Selecciona una opción para Buscar Paciente")
print ("\t1 - Por DNI")
print ("\t2 - Por nombre")
print ("\t3 - Por edad")
print ("\t9 - salir")
def Lista_Paciente(p):
while True:
menuListap()
opcionMenu = input("inserta un numero valor >> ")
if opcionMenu=="1":
#POR DNI
dni = int(input("Ingrese DNI: "))
p.execute("SELECT * FROM PACIENTES WHERE DNI='dni'")
paciente = p.fetchall()
print(paciente)
elif opcionMenu=="2":
#POR NOMBRE
nombre = str(input("Ingrese nombre: "))
p.execute("SELECT * FROM PACIENTES WHERE NOMBRE_PACIENTE= '?'", nombre)
paciente = p.fetchall()
print(paciente)
elif opcionMenu=="3":
#POR EDAD
edad = int(input("Ingrese edad: "))
p.execute("SELECT * FROM PACIENTES WHERE EDAD= '?'", edad)
paciente = p.fetchall()
print(paciente)
elif opcionMenu=="9":
break
else:
print ("")
input("No has pulsado ninguna opción correcta...\npulsa una tecla para continuar")
At my discretion, the error is found at the moment I try to enter the variable both ID, name and age to the sql code.
PS: if in the part of p.execute("SELECT * FROM PACIENTES WHERE DNI='dni'")
instead of putting the variable dni I enter the ID number ( p.execute("SELECT * FROM PACIENTES WHERE DNI='40396902'")
) in if I execute it perfectly but the idea is to be entered by keyboard and not manually.