Skip to content

Commit

Permalink
Fix for no such table: pragma_database_list, refs #1276
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Mar 28, 2021
1 parent 3fcfc85 commit 48d5e0e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions datasette/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,12 @@ def mtime_ns(self):
return Path(self.path).stat().st_mtime_ns

async def attached_databases(self):
results = await self.execute(
"select seq, name, file from pragma_database_list() where seq > 0"
)
return [AttachedDatabase(*row) for row in results.rows]
# This used to be:
# select seq, name, file from pragma_database_list() where seq > 0
# But SQLite prior to 3.16.0 doesn't support pragma functions
results = await self.execute("PRAGMA database_list;")
# {'seq': 0, 'name': 'main', 'file': ''}
return [AttachedDatabase(*row) for row in results.rows if row["seq"] > 0]

async def table_exists(self, table):
results = await self.execute(
Expand Down

0 comments on commit 48d5e0e

Please sign in to comment.