I want to extract data from a sqlite table into a list and pass this very list to the html template. I tried it like this:

query= "SELECT * from columnes where name_music= '{name}'". format (name= name)
query1= "SELECT * from article where name_music= '{name}'". format (name= name)
articule= cursor.execute (query1)
articule= articule.fetchall ()
d= cursor.execute (query)
d= d.fetchall ()
print (articule [0] [0])
return render_template ('composition.html', comp= d, comp1= articule)

However, when I try to print an element using print, I get an error:

Maybe someone knows how to fix this? Or does anyone know of other ways to fetch data from the database? Thank you in advance! P.S. I would also like to say that the article table contains one element (it is not empty).

First, write just print (articule), let's see what it is equal to

alex2021-11-24 07:33:11

Why is your code duplicated twice? )

CrazyElf2021-11-24 07:33:11

alex, in this case nothing is displayed

Neon Light2021-11-24 07:33:11

@CrazyElf, corrected

Neon Light2021-11-24 07:33:11

Please do not add code and /or errors in the form of screenshots. It is inconvenient to read, impossible to copy. Add text to the question (button edit)

gil9red2021-11-23 09:00:46