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)])

```
```
def getUsers(self,assoc=False):
        result = self.cursor.execute("SELECT * FROM users").fetchall()
        result_len = len(result)
        if(result_len == False): return
        if(assoc != True):
            return result
        else:
            result_formated = []
            columns = [column[0] for column in self.cursor.description]
            for row in result:
                row_dict = {}
                i = 0
                # print(result_len)
                while(i <= result_len):
                    row_dict[columns[i]] = row[i]
                    i += 1
                result_formated.append(row_dict)
            return result_formated

```

i'll just leave my bad code here