![]() |
Python Variables and Sqlite3 Database - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Python Variables and Sqlite3 Database (/thread-33762.html) |
Python Variables and Sqlite3 Database - Staples200 - May-25-2021 Is there any way to pull each column entry and make each db entry it's own variable? I know how to pull a single entry at a time using something like for rows in cursor.execute("SELECT commands FROM CR WHERE ID = [1]): variable=rows print(variable) else: variable = 0 But I need a way to make variable1 = (column entry 1), Variable2 = (column entry 2), so on and so forth. I'm assuming I would have to use arrays but can't find any guidance online. Any help would be greatly appreciated. Thanks. RE: Python Variables and Sqlite3 Database - Staples200 - May-25-2021 I figured it out. If anyone else needs to do this... Here is the correct code... for i in range(1,3): print(i) cur.execute("SELECT commands FROM CR WHERE ID=?", (i,)) |