mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Improvements + docs for db.execute() and Results class
* Including new results.first() and results.single_value() methods. Closes #685
This commit is contained in:
parent
69e3a855dd
commit
4433306c18
8 changed files with 141 additions and 29 deletions
|
|
@ -47,27 +47,6 @@ ENV SQLITE_EXTENSIONS /usr/lib/x86_64-linux-gnu/mod_spatialite.so
|
|||
"""
|
||||
|
||||
|
||||
class QueryInterrupted(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class Results:
|
||||
def __init__(self, rows, truncated, description):
|
||||
self.rows = rows
|
||||
self.truncated = truncated
|
||||
self.description = description
|
||||
|
||||
@property
|
||||
def columns(self):
|
||||
return [d[0] for d in self.description]
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self.rows)
|
||||
|
||||
def __len__(self):
|
||||
return len(self.rows)
|
||||
|
||||
|
||||
def urlsafe_components(token):
|
||||
"Splits token on commas and URL decodes each component"
|
||||
return [urllib.parse.unquote_plus(b) for b in token.split(",")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue