Answer the question
In order to leave comments, you need to log in
How to use a loop to look at the entire database and pull out individual columns?
The bottom line is, I need to somehow check the entire database and pull out all the id's of records from it, where for example the name is Maxim and write this data to a variable, please tell me how to do this
Answer the question
In order to leave comments, you need to log in
It is worth saying that set() selects elements randomly, so if the task is also to build all the ids in order, you need to use: result.sorted()
with sq.connect("database.db") as con:
cur = con.cursor()
names = list(set(cur.execute("select id from table where name = 'Максим'").fetchall()))
result= [x[0] for x in names]
print(result)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question