duckdb-wasm icon indicating copy to clipboard operation
duckdb-wasm copied to clipboard

Opening duckdb files in web shell isn't possible

Open noppaz opened this issue 3 years ago • 2 comments

Trying to query tables from a duckdb file database isn't possible in the Web Shell as the .open command doesn't actually connect to it.

Steps:

  1. Add file.duckdb with .files add
  2. Open it with .open file.duckdb
  3. The text Connected to a local transient in-memory database. changes to Connected to a read-only remote database at: file.duckdb.

Expected tables are still not there to query. This can be verified by checking 0 rows returned from PRAGMA show_tables;. If we check PRAGMA database_list; the result implies it still uses the in memory database:

┌─────┬──────┬──────────┐
│ seq ┆ name ┆ file     │
╞═════╪══════╪══════════╡
│   0 ┆ main ┆ :memory: │
└─────┴──────┴──────────┘

As a bonus remark; I also noticed that it's possible to open any filename with the open command. For example, running .open doesnt-exist.duckdb will change the connection text to Connected to a read-only remote database at: doesnt-exist.duckdb.

noppaz avatar Aug 10 '22 14:08 noppaz

Hi! Proper support for multiple databases landed in DuckDB 0.7 (https://duckdb.org/2023/02/13/announcing-duckdb-070.html#multi-database-support) and that would make implement this more trivial (and potentially make .open obsolete altogether).

In paricular ATTACH 'someDatabase.duckdb' is the SQL version of .open, and can also be chained with USE 'someDatabase.duckdb, and I just tested that works with live https://shell.duckdb.org.

This can stay open until we figure out this properly, but a workaround / a better workflow it's already present.

carlopi avatar Mar 16 '23 20:03 carlopi