Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqlite driver should support attaching a database #324

Open
neilotoole opened this issue Nov 12, 2023 · 0 comments
Open

sqlite driver should support attaching a database #324

neilotoole opened this issue Nov 12, 2023 · 0 comments

Comments

@neilotoole
Copy link
Owner

neilotoole commented Nov 12, 2023

Is your feature request related to a problem? Please describe.

Other drivers (e.g. Postgres) have inherent support for SQL SCHEMA (and usually CATALOG). SQLite doesn't have CATALOG support, but by attaching a database, it effectively has SCHEMA support.

Issue #270 exposes the ability to switch schema per query. But we can't implement this functionality for SQLite until there's a means to attach databases.

Describe the solution you'd like
It should be possible to attach databases to a SQLite source, at a minimum, after the source has been added, and maybe when creating the soruce. An example implementation might be:

# Attach when adding the source (maybe?)
$ sq add --driver=sqlite3 ./main.db --attach ./sales.db --attach-as sales

# Attach after the fact
$ sq src attach @sqlite ./sales.db
$ sq src attach @sqlite ./inventory.db --name inven

$ sq src detach @sqlite sales
$ sq src detach @sqlite inven

Note that the sq src attach form is only an example of a possible implementation. Maybe sq config edit @sqlite or such could work too.

Describe alternatives you've considered
N/A

Additional context

  • Do we need a means to list the attached databases?
  • Would the attached databases show up in sq src (get source details), or maybe sq src -j?
  • How to store details in the config file? Maybe something like:
handle: "@sakila/sl3"
driver: sqlite3
location: sqlite3:///Users/neilotoole/work/sq/sq/drivers/sqlite3/testdata/sakila.db
extra:
  sqlite3:
    attach:
      - name: sales
        path: ./sales.db
      - name: inven
        path: ./inventory.db
  • Should the path of the attached db be stored as an absolute filepath, or as relative to the main db file (whose filepath is already stored as an absolute path)?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant