mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
results.dicts() method, closes #2414
This commit is contained in:
parent
dc288056b8
commit
92c4d41ca6
6 changed files with 28 additions and 17 deletions
|
|
@ -677,6 +677,9 @@ class Results:
|
|||
else:
|
||||
raise MultipleValues
|
||||
|
||||
def dicts(self):
|
||||
return [dict(row) for row in self.rows]
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self.rows)
|
||||
|
||||
|
|
|
|||
|
|
@ -277,8 +277,7 @@ class RowUpdateView(BaseView):
|
|||
results = await resolved.db.execute(
|
||||
resolved.sql, resolved.params, truncate=True
|
||||
)
|
||||
rows = list(results.rows)
|
||||
result["row"] = dict(rows[0])
|
||||
result["row"] = results.dicts()[0]
|
||||
|
||||
await self.ds.track_event(
|
||||
UpdateRowEvent(
|
||||
|
|
|
|||
|
|
@ -558,7 +558,7 @@ class TableInsertView(BaseView):
|
|||
),
|
||||
args,
|
||||
)
|
||||
result["rows"] = [dict(r) for r in fetched_rows.rows]
|
||||
result["rows"] = fetched_rows.dicts()
|
||||
else:
|
||||
result["rows"] = rows
|
||||
# We track the number of rows requested, but do not attempt to show which were actually
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue