i have a list of unique names that i pulled from an sqlite database using the following code:
connection = sqlite3.connect('database.sqlite')
connection.text_factory = str
c = connection.cursor()
c.execute ('SELECT Name FROM Table WHERE Description LIKE ?', [term])
my_object = []
for name in c:
my_object.append(name)
return my_object
i want to use this list of unique names to look through another table in the same database and pull out four values. i.e. – ‘SELECT value1, value2, value3, value4 FROM Table2 WHERE Name LIKE ___‘ where the blank would be each of the values in my list. this is the part i really need help on
i then want to make an HTML table with the Name in the first column and all the corresponding values in the subsequent values (i know the HTML, but don’t know how to lump all of this together using python). if i could pull each value separately, i guess i could use zip to combine them and loop through the table, but i was hoping to do this in as few steps as possible.
i hope i’m being clear.
You could amend your SQL so that you pull out the names that are like a certain description, and then put out values from table2 for those matching names.