mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-24 01:44:31 +02:00
New db.query() method, refs #290
This commit is contained in:
parent
8cedc6a8b2
commit
9faeef230b
3 changed files with 31 additions and 28 deletions
|
|
@ -359,10 +359,14 @@ class Database:
|
|||
for table in tables
|
||||
)
|
||||
|
||||
def execute_returning_dicts(self, sql, params=None):
|
||||
def query(self, sql, params=None):
|
||||
cursor = self.execute(sql, params or tuple())
|
||||
keys = [d[0] for d in cursor.description]
|
||||
return [dict(zip(keys, row)) for row in cursor.fetchall()]
|
||||
for row in cursor:
|
||||
yield dict(zip(keys, row))
|
||||
|
||||
def execute_returning_dicts(self, sql, params=None):
|
||||
return list(self.query(sql, params))
|
||||
|
||||
def resolve_foreign_keys(self, name, foreign_keys):
|
||||
# foreign_keys may be a list of strcolumn names, a list of ForeignKey tuples,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue