projects
/
datasette-pytables.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
ecde481
)
Resolve queries by rowid (nrow)
author
Javier Sancho
<jsf@jsancho.org>
Mon, 14 May 2018 10:18:39 +0000
(12:18 +0200)
committer
Javier Sancho
<jsf@jsancho.org>
Mon, 14 May 2018 10:18:39 +0000
(12:18 +0200)
datasette_pytables/__init__.py
patch
|
blob
|
history
diff --git
a/datasette_pytables/__init__.py
b/datasette_pytables/__init__.py
index 3c71267e9f1144cff2d2c02c32c74264bc223a7d..50180fdc5c35c1d6ae93d817080dabd6d824ed9d 100644
(file)
--- a/
datasette_pytables/__init__.py
+++ b/
datasette_pytables/__init__.py
@@
-43,6
+43,8
@@
def _parse_sql(sql):
else:
current_keyword = str(token)
parsed_sql[current_keyword] = ""
else:
current_keyword = str(token)
parsed_sql[current_keyword] = ""
+ elif type(token) is sqlparse.sql.Where:
+ parsed_sql['where'] = token
else:
if not token.is_whitespace:
parsed_sql[current_keyword] += str(token)
else:
if not token.is_whitespace:
parsed_sql[current_keyword] += str(token)
@@
-65,7
+67,17
@@
class Connection:
# Use 'where' statement or get all the rows
if 'where' in parsed_sql:
# Use 'where' statement or get all the rows
if 'where' in parsed_sql:
- pass
+ query = ''
+ start = 0
+ end = table.nrows
+ for condition in parsed_sql['where'].get_sublists():
+ if str(condition) == '"rowid"=:p0':
+ start = int(params['p0'])
+ end = start + 1
+ if query:
+ table_rows = table.where(query, start, end)
+ else:
+ table_rows = table.iterrows(start, end)
else:
table_rows = table.iterrows()
else:
table_rows = table.iterrows()