(self, query)
| 90 | ) |
| 91 | |
| 92 | def query(self, query): |
| 93 | cur = self.conn.cursor() |
| 94 | cur.execute(query) |
| 95 | |
| 96 | # Collect the results into a list of dicts. |
| 97 | res = [] |
| 98 | for r in cur: |
| 99 | t = {} |
| 100 | # Zip the column definition with the value to get its name. |
| 101 | for c, v in zip(cur.description, r): |
| 102 | t[c.name] = v |
| 103 | res.append(t) |
| 104 | cur.close() |
| 105 | return res |
| 106 | |
| 107 | def execute(self, query: str, params: tuple = ()) -> None: |
| 108 | """Execute a single statement with bound params. Placeholders: '%s'""" |