1
I have a database with a list_students table, str(name) field and str(serie) field, someone can explain me why I can’t access the names that contain only the series I passed?
conn = sqlite3.connect('bd/obj.db')
c = conn.cursor()
c.execute('SELECT nome FROM lista_alunos WHERE serie = ?', botao.text,)
for i in c.fetchall():
print(i[3])
conn.close()
Botao.text is also a string.
Your query returns only one column and in the loop
for
you try to print a missing fourth column. Where isprint(i[3])
doprint(i[0])
.– Augusto Vasques
I had already tested, and I was able to access i[0] by buffering (botao.text). What I found very strange because when I try with other columns it accepts without buffer.
– Fernando Foster
In the
execute
has an extra comma afterbotao.text
.– Augusto Vasques
Actually the comma is necessary because the second argument is a tuple, but even the way it is, when I access another column that is not serial it prints the values normally.
– Fernando Foster
I managed to solve, I changed the way I write the data in the comic book, I took sqlite3.Inary() and it worked.
– Fernando Foster