Skip to content

Commit

Permalink
Replaced self.ds.execute with db.execute in more places
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Feb 14, 2020
1 parent efa54b4 commit f1442a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
3 changes: 1 addition & 2 deletions datasette/database.py
Expand Up @@ -300,8 +300,7 @@ async def get_table_definition(self, table, type_="table"):
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},
)
Expand Down
12 changes: 4 additions & 8 deletions datasette/views/table.py
Expand Up @@ -533,17 +533,13 @@ async def data(
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
Expand Down Expand Up @@ -795,7 +791,7 @@ async def data(self, request, database, hash, table, pk_path, default_labels=Fal
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:
Expand Down Expand Up @@ -876,7 +872,7 @@ async def foreign_key_tables(self, database, table, pk_values):
]
)
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 []
Expand Down

0 comments on commit f1442a8

Please sign in to comment.