projects
/
datasette-pytables.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4d7f832
)
Use max_returned_rows in conjuction with page_size for truncating
author
Javier Sancho
<jsf@jsancho.org>
Fri, 25 May 2018 10:23:02 +0000
(12:23 +0200)
committer
Javier Sancho
<jsf@jsancho.org>
Fri, 25 May 2018 10:23:02 +0000
(12:23 +0200)
datasette_pytables/__init__.py
patch
|
blob
|
history
diff --git
a/datasette_pytables/__init__.py
b/datasette_pytables/__init__.py
index d9530ae9a7edb969a64628c018d2b2c83d29c051..93cc1f082fd6eef31e0250ef644080cf4474303c 100644
(file)
--- a/
datasette_pytables/__init__.py
+++ b/
datasette_pytables/__init__.py
@@
-71,7
+71,7
@@
class Connection:
self.path = path
self.h5file = tables.open_file(path)
self.path = path
self.h5file = tables.open_file(path)
- def execute(self, sql, params=None, truncate=False, page_size=None):
+ def execute(self, sql, params=None, truncate=False, page_size=None
, max_returned_rows=None
):
if params is None:
params = {}
rows = []
if params is None:
params = {}
rows = []
@@
-145,9
+145,11
@@
class Connection:
end = start + max_rows
# Truncate if needed
end = start + max_rows
# Truncate if needed
- if page_size and truncate:
- if end - start > page_size:
- end = start + page_size
+ if page_size and max_returned_rows and truncate:
+ if max_returned_rows == page_size:
+ max_returned_rows += 1
+ if end - start > max_returned_rows:
+ end = start + max_returned_rows
truncated = True
# Execute query
truncated = True
# Execute query