Currently I have the following code:
c.execute("SELECT * FROM table")
for row in c.fetchall():
print row[0]
print row[1]
However, I changed the structure of my table and now I have to change the index values to represent this change. Is there a way to get use column names instead?
See Row Objects in the docs for the sqlite3 module. If you use the sqlite3.Row
row_factory you'll get back an object that's slightly more powerful than the normal tuples. I imagine it has slightly higher overhead, hence not being the default behavior.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With