Answer the question
In order to leave comments, you need to log in
How to get all the values of a column into a list from a database?
Hello, you need to get all the values of one column from the database.
Let's say there are many users and you need to take their ID from each and write them into one list, how to implement this?
Answer the question
In order to leave comments, you need to log in
If you use the sqlite3 engine to work with the database, then it will be something like this
con = sqlite3.connect("mydb.sqlite") #подразумеваю, что таблицу ты уже создал
cur = con.cursor()
cur.execute("SELECT id FROM users")
ids = [row['id'] for row in cur]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question