1
Good afternoon!
I created a function that updates the "mylistcolum" list according to the fields of a table searched in sqlserver. The event that activates this function is the click on a list of tables that is displayed at the beginning of the program. the problem I’m having is that the list of fields instead of being replaced when I click on a new table, is adding the new fields. Instead of staying:
table a: a. name, end, number table b: b. home, b.car, b.schooling
is getting:
table a: a. name, end, number table b: a. name, a.end, a.numero, b.casa, b.carro, b.escolaridade
def getTabela(event):
lista = []
#aux = 0
#while aux < mylistcolum.size():
# if mylistcolum.size() > 0:
# del mylistcolum[aux]
if mylist.size() > 0:
tabela = mylist.get(ACTIVE)
#label.configure(text=tabela)
cur.execute("select COLUMN_NAME from information_schema.columns where table_name ='" + tabela+"'")
dadosColum = cur.fetchall()
for dados in dadosColum:
if len(dados) > 0:
lista.append(dados[0])
for line in lista:
mylistcolum.insert(END, str(line))