Skip to content

Group several SQLite files under one connection #2536

Closed

Description

@datlechin

Problem

Each SQLite file is its own connection. A project holding several, which is normal when a schema is split by concern, fills the connection list with entries that belong together. A file attached with ATTACH in the editor can be queried as alias.table, but databases/sqlite.mdx (Browsing) says it "never appears in the sidebar": the object list reads the main database only. The attachment is gone after a reconnect, so it has to be typed again.

DuckDB is halfway there: an attached file joins the sidebar as a sibling database after a refresh and Cmd+K switches to it, but DuckDB does not persist attachments, so a reconnect starts again from the one file (databases/duckdb.mdx).

Proposed solution

  • Several file paths on one SQLite connection, each attached under a name the user picks, defaulting to the file name.
  • Each attached database as its own node in the sidebar, with its tables under it, browsable and editable like the main one.
  • Cross-database queries work, since ATTACH is what makes them work, and completion knows alias.table.
  • The attachments are part of the saved connection, so every connect, reconnect and restored tab attaches them again before anything runs.
  • The same for DuckDB local files and libSQL local files, which use the same ATTACH.
  • A file that is missing at connect time fails with its path named, and the rest still attach.

Done means a connection saved with app.db, auth.db and audit.db lists three databases in the sidebar after a relaunch, and SELECT … FROM auth.users JOIN audit.events … runs.

Alternatives considered

One connection per file, and ATTACH typed again after every reconnect.

Platform

macOS

Related database type

SQLite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions