Skip to content

Commit

Permalink
Don't expect _datasette_extract table to exist
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Mar 7, 2024
1 parent aa5ff9d commit f7ac2c0
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions datasette_extract/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,22 @@ async def extract_to_table(datasette, request, scope, receive):
)

# Restore properties from previous run, if possible
previous_runs = [
dict(row)
for row in (
await db.execute(
"""
select id, database_name, table_name, created, properties, completed, error, num_items
from _datasette_extract
where database_name = :database_name and table_name = :table_name
order by id desc limit 20
""",
{"database_name": database, "table_name": table},
)
).rows
]
previous_runs = []
if await db.table_exists("_datasette_extract"):
previous_runs = [
dict(row)
for row in (
await db.execute(
"""
select id, database_name, table_name, created, properties, completed, error, num_items
from _datasette_extract
where database_name = :database_name and table_name = :table_name
order by id desc limit 20
""",
{"database_name": database, "table_name": table},
)
).rows
]

columns = [
{"name": name, "type": value, "hint": "", "checked": True}
Expand Down

0 comments on commit f7ac2c0

Please sign in to comment.