From f1442a8151f66ceef6517b6d3d045e2ec1d0f0ec Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 13 Feb 2020 18:20:05 -0800 Subject: [PATCH] Replaced self.ds.execute with db.execute in more places --- datasette/database.py | 3 +-- datasette/views/table.py | 12 ++++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/datasette/database.py b/datasette/database.py index 875dac20..8d19bd74 100644 --- a/datasette/database.py +++ b/datasette/database.py @@ -300,8 +300,7 @@ class Database: bits = [table_definition_rows[0][0] + ";"] # Add on any indexes index_rows = list( - await self.ds.execute( - self.name, + await self.execute( "select sql from sqlite_master where tbl_name = :n and type='index' and sql is not null", {"n": table}, ) diff --git a/datasette/views/table.py b/datasette/views/table.py index 54839344..140f2a15 100644 --- a/datasette/views/table.py +++ b/datasette/views/table.py @@ -533,17 +533,13 @@ class TableView(RowTableShared): if request.raw_args.get("_timelimit"): extra_args["custom_time_limit"] = int(request.raw_args["_timelimit"]) - results = await self.ds.execute( - database, sql, params, truncate=True, **extra_args - ) + results = await db.execute(sql, params, truncate=True, **extra_args) # Number of filtered rows in whole set: filtered_table_rows_count = None if count_sql: try: - count_rows = list( - await self.ds.execute(database, count_sql, from_sql_params) - ) + count_rows = list(await db.execute(count_sql, from_sql_params)) filtered_table_rows_count = count_rows[0][0] except QueryInterrupted: pass @@ -795,7 +791,7 @@ class RowView(RowTableShared): params = {} for i, pk_value in enumerate(pk_values): params["p{}".format(i)] = pk_value - results = await self.ds.execute(database, sql, params, truncate=True) + results = await db.execute(sql, params, truncate=True) columns = [r[0] for r in results.description] rows = list(results.rows) if not rows: @@ -876,7 +872,7 @@ class RowView(RowTableShared): ] ) try: - rows = list(await self.ds.execute(database, sql, {"id": pk_values[0]})) + rows = list(await db.execute(sql, {"id": pk_values[0]})) except sqlite3.OperationalError: # Almost certainly hit the timeout return []