Answer the question
In order to leave comments, you need to log in
Loop for cursor.execute in sqlite?
There is a table of products and a table of images
Each product has an id cell, each image has an id_product cell to which it is attached
. A product may not have an image.
I'm trying
# Делаю цикл в котором достаем все из таблицы товаров
for product in cursor.execute("SELECT rowid, * FROM products_product "):
print("Название товара: ", product[2])
print("id", product[0])
print( "Ценна:" , product[3], "грн")
#теперь ищем картинку
product_id = product[0]
media = cursor.execute('SELECT * FROM products_product_media WHERE product_id=?', str(product_id))
media = media.fetchone()
print("Путь к картинке:" , media[1])
#теперь ищем картинку
product_id = product[0]
media = cursor.execute('SELECT * FROM products_product_media WHERE product_id=?', str(product_id))
media = media.fetchone()
print("Путь к картинке:" , media[1])
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question