Replaced self.ds.execute with db.execute in more places

prepare-connection-datasette
Simon Willison 2020-02-13 18:20:05 -08:00
rodzic efa54b439f
commit f1442a8151
2 zmienionych plików z 5 dodań i 10 usunięć

Wyświetl plik

@ -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},
)

Wyświetl plik

@ -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 []