I am still a novice in Python and I have a problem that has not been solved. I am creating a form to feed / view / modify ... records from a database in PostgreSQL and among other options I want to dump the data from the database to a Treeview ( tabla1
) to see them as a table.
The fact is that as is my code works well, but with an incidence, and that is that I omits the first line of the database . I've been trying to locate the error for days and I do not know where it is.
This is the code:
def vertablaentera():
tabla=cajan.get()
while tabla!="familia" and tabla!="telefonos":
tkMessageBox.showerror("Administrador","La tabla introducida es erronea")
cajan.delete(0,END)
break
if tabla=="familia":
cursor.execute("SELECT * FROM familia")
verRegistros=cursor.fetchone()
#la linea anterior utiliza fetchone y no fetchall porque el bucle de abajo recorre uno a uno los registros
if not verRegistros:
tkMessageBox.showinfo("Administrador","No existen datos")
else:
#tkMessageBox.showinfo("INFORMACIO SOLICITADA",verRegistros)
id=0
for row in cursor:
tabla1.insert("",index="end",text=str(id),value=(row[1],row[2],row[3]))
id+=1