From 5247856bd42d95f21e389c127d1c574961ee16d6 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 30 Oct 2025 15:44:06 -0700 Subject: [PATCH] Filter out temp database from attached_databases() Refs https://github.com/simonw/datasette/issues/2557#issuecomment-3470510837 --- datasette/database.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/datasette/database.py b/datasette/database.py index 13baa1d9..e5858128 100644 --- a/datasette/database.py +++ b/datasette/database.py @@ -410,7 +410,12 @@ class Database: # 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] + return [ + AttachedDatabase(*row) + for row in results.rows + # Filter out the SQLite internal "temp" database, refs #2557 + if row["seq"] > 0 and row["name"] != "temp" + ] async def table_exists(self, table): results = await self.execute(