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: 
Shorter version:

```
db.row_factory = lambda c, r: dict([(col[0], r[idx]) for idx, col in enumerate(c.description)])

```
**Get the results of the query**

```
output_obj = con.execute(query)
results = output_obj.fetchall()

```

**Option 1) Explicit Loop w/ Zip**

```
for row in results:
    col_names = [tup[0] for tup in output_obj.description]
    row_values = [i for i in row]
    row_as_dict = dict(zip(col_names,row_values))

```

**Option 2) Faster Loop w/ Dict Comp**

```
for row in results:
    row_as_dict = {output_obj.description[i][0]:row[i] for i in range(len(row))}

```