Question: ```
db = sqlite.connect("test.sqlite")
res = db.execute("select * from table")

```

With iteration I get lists coresponding to the rows.

```
for row in res:
    print row

```

I can get name of the columns

```
col_name_list = [tuple[0] for tuple in res.description]

```

But is there some function or setting to get dictionaries instead of list?

```
{'col1': 'value', 'col2': 'value'}

```

or I have to do myself?

Answer: 
I thought I answer this question even though the answer is partly mentioned in both Adam Schmideg's and Alex Martelli's answers. In order for others like me that have the same question, to find the answer easily.

```
conn = sqlite3.connect(":memory:")

#This is the important part, here we are setting row_factory property of
#connection object to sqlite3.Row(sqlite3.Row is an implementation of
#row_factory)
conn.row_factory = sqlite3.Row
c = conn.cursor()
c.execute('select * from stocks')

result = c.fetchall()
#returns a list of dictionaries, each item in list(each dictionary)
#represents a row of the table

```
Even using the sqlite3.Row class-- you still can't use string formatting in the form of:

```
print "%(id)i - %(name)s: %(value)s" % row

```

In order to get past this, I use a helper function that takes the row and converts to a dictionary. I only use this when the dictionary object is preferable to the Row object (e.g. for things like string formatting where the Row object doesn't natively support the dictionary API as well). But use the Row object all other times. 

```
def dict_from_row(row):
    return dict(zip(row.keys(), row))       

```