I\'m using sqlite3 in python 2.5. I\'ve created a table that looks like this:
create table votes (
bill text,
senator_id text,
vote text)
<
There is actually an option for this in sqlite3. Change the row_factory
member of the connection object to sqlite3.Row
:
conn = sqlite3.connect('db', row_factory=sqlite3.Row)
or
conn.row_factory = sqlite3.Row
This will allow you to access row elements by name--dictionary-style--or by index. This is much more efficient than creating your own work-around.