From b61c78ff44e9c719615cc6955c63cb732be55847 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Mon, 14 May 2018 12:18:39 +0200 Subject: [PATCH 1/1] Resolve queries by rowid (nrow) --- datasette_pytables/__init__.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/datasette_pytables/__init__.py b/datasette_pytables/__init__.py index 3c71267..50180fd 100644 --- 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] = "" + elif type(token) is sqlparse.sql.Where: + parsed_sql['where'] = 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: - 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() -- 2.39.2