duckdb / duckdb-wasm

WebAssembly version of DuckDB
https://shell.duckdb.org
MIT License
1.25k stars 132 forks source link

Opening duckdb files in web shell isn't possible #933

Open noppaz opened 2 years ago

noppaz commented 2 years ago

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.

carlopi commented 1 year ago

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.

lpfy commented 2 months ago

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.

Hi @carlopi, when attach a xxx.db file, the console print out warning message "Buffering missing file: xxx.db.wal", just wondering how to disable this warning? Everything is running fine, .db.wal was also created when checked by using ".files list" command. The warning message is just bit annoying...