duckdb / sqlite_scanner

DuckDB extension to read and write to SQLite databases
https://duckdb.org/docs/extensions/sqlite
MIT License
208 stars 21 forks source link

Unable to attach sqllite database, empty error #7

Closed adagrad closed 1 year ago

adagrad commented 2 years ago

How could I bypass this error:

D LOAD 'extension/sqlite_scanner/sqlite_scanner.duckdb_extension';
Error: IO Error: Extension "extension/sqlite_scanner/sqlite_scanner.duckdb_extension" could not be loaded because its signature is either missing or invalid and unsigned extensions are disabled by configuration (allow_unsigned_extensions)
Mytherin commented 2 years ago

For the shell you can pass the -unsigned flag at start-up, e.g.:

duckdb -unsigned
adagrad commented 2 years ago

That works but leaves me with an empty error:

./duckdb -unsigned foo.duckdb
v0.4.1-dev1115 e95fb4c30
Enter ".help" for usage hints.
D LOAD 'extension/sqlite_scanner/sqlite_scanner.duckdb_extension';
D CALL sqlite_attach('/tmp/fin.quote.sqlite');
Error:
D
bzbzbz commented 1 year ago

I'm having a similar issue following the path recommended by the docs/help (DuckDB 0.5.1) Same effect if I start the CLI with --unsigned or not:

v0.5.1 7c111322d
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
D
D CALL sqlite_attach('/srv/sample-data.db');
Error: Catalog Error: Function with name sqlite_attach is not on the catalog, but it exists in the sqlite_scanner extension. To Install and Load the extension, run: INSTALL sqlite_scanner; LOAD sqlite_scanner;
D
D INSTALL sqlite_scanner;
D LOAD sqlite_scanner;
D
D CALL sqlite_attach('/srv/sample-data.db');
Error: Invalid Error:

Oddly, the sqlite_scanner extension shows up as installed, but not loaded, even after calling LOAD sqlite_scanner;:

D LOAD sqlite_scanner;
D select * From duckdb_extensions();
┌──────────────────┬────────┬───────────┬────────────────────────────────────────────────────────────────────────────────────┬──────────────────────────────────────────────────────────────────────┐
│  extension_name  │ loaded │ installed │                                    install_path                                    │                             description                              │
├──────────────────┼────────┼───────────┼────────────────────────────────────────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────┤
│ excel            │ true   │           │                                                                                    │                                                                      │
│ fts              │ true   │ true      │ (BUILT-IN)                                                                         │ Adds support for Full-Text Search Indexes                            │
│ httpfs           │ false  │ false     │                                                                                    │ Adds support for reading and writing files over a HTTP(S) connection │
│ icu              │ true   │ true      │ (BUILT-IN)                                                                         │ Adds support for time zones and collations using the ICU library     │
│ json             │ true   │ true      │ (BUILT-IN)                                                                         │ Adds support for JSON operations                                     │
│ parquet          │ true   │ true      │ (BUILT-IN)                                                                         │ Adds support for reading and writing parquet files                   │
│ postgres_scanner │ false  │ false     │                                                                                    │ Adds support for reading from a Postgres database                    │
│ sqlite_scanner   │ false  │ true      │ /home/username/.duckdb/extensions/v0.5.1/linux_amd64/sqlite_scanner.duckdb_exten... │ Adds support for reading SQLite database files                       │
│ tpcds            │ false  │ false     │                                                                                    │ Adds TPC-DS data generation and query support                        │
│ tpch             │ true   │ true      │ (BUILT-IN)                                                                         │ Adds TPC-H data generation and query support                         │
│ visualizer       │ true   │           │                                                                                    │                                                                      │
└──────────────────┴────────┴───────────┴────────────────────────────────────────────────────────────────────────────────────┴──────────────────────────────────────────────────────────────────────┘
Alex-Monahan commented 1 year ago

Try wrapping it in single quotes when you install and load. Does that help?

install 'sqlite_scanner';
load 'sqlite_scanner';
bzbzbz commented 1 year ago

@Alex-Monahan

Unfortuantely not. Same error:

v0.5.1 7c111322d
Enter ".help" for usage hints.
D
D
D install 'sqlite_scanner';
D load 'sqlite_scanner';
D
D
D select * From duckdb_extensions();
┌──────────────────┬────────┬───────────┬────────────────────────────────────────────────────────────────────────────────────┬──────────────────────────────────────────────────────────────────────┐
│  extension_name  │ loaded │ installed │                                    install_path                                    │                             description                              │
├──────────────────┼────────┼───────────┼────────────────────────────────────────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────┤
│ excel            │ true   │           │                                                                                    │                                                                      │
│ fts              │ true   │ true      │ (BUILT-IN)                                                                         │ Adds support for Full-Text Search Indexes                            │
│ httpfs           │ false  │ false     │                                                                                    │ Adds support for reading and writing files over a HTTP(S) connection │
│ icu              │ true   │ true      │ (BUILT-IN)                                                                         │ Adds support for time zones and collations using the ICU library     │
│ json             │ true   │ true      │ (BUILT-IN)                                                                         │ Adds support for JSON operations                                     │
│ parquet          │ true   │ true      │ (BUILT-IN)                                                                         │ Adds support for reading and writing parquet files                   │
│ postgres_scanner │ false  │ false     │                                                                                    │ Adds support for reading from a Postgres database                    │
│ sqlite_scanner   │ false  │ true      │ /home/username/.duckdb/extensions/v0.5.1/linux_amd64/sqlite_scanner.duckdb_exten... │ Adds support for reading SQLite database files                       │
│ tpcds            │ false  │ false     │                                                                                    │ Adds TPC-DS data generation and query support                        │
│ tpch             │ true   │ true      │ (BUILT-IN)                                                                         │ Adds TPC-H data generation and query support                         │
│ visualizer       │ true   │           │                                                                                    │                                                                      │
└──────────────────┴────────┴───────────┴────────────────────────────────────────────────────────────────────────────────────┴──────────────────────────────────────────────────────────────────────┘
D
D CALL sqlite_attach('/srv/sample-data.db');
Error: Invalid Error:
ccwang002 commented 1 year ago

On mac arm64 (m1 pro), I got the same error that the extension was not available after running make:

./build/release duckdb -unsigned 
D LOAD 'build/release/extension/sqlite_scanner/sqlite_scanner.duckdb_extension';
================================================================================
IO Error: Extension "build/release/extension/sqlite_scanner/sqlite_scanner.duckdb_extension" not found
Mause commented 1 year ago

On mac arm64 (m1 pro), I got the same error that the extension was not available after running make:

./build/release duckdb -unsigned 
D LOAD 'build/release/extension/sqlite_scanner/sqlite_scanner.duckdb_extension';
================================================================================
IO Error: Extension "build/release/extension/sqlite_scanner/sqlite_scanner.duckdb_extension" not found

Does that file actually exist on disk?

Looks like this change was missed: https://github.com/duckdblabs/sqlite_scanner/pull/11

Try again with that change?

ccwang002 commented 1 year ago

I was able to create the duckdb extension with #11. make test on mac arm64 now passes all the tests as well. Awesome! Thank you for the quick fix 🎉

Note that the tpch.db needs to be created before running the tests:

./build/release/duckdb < tpch-export.duckdb
sqlite3 tpch.db < tpch-create.sqlite
Mause commented 1 year ago

It looks like the root cause of this issue may be a symbol collision error (the copy of sqlite3 in the extension being overwritten by the sqlite_api_wrapper used by the DuckDB cli).

@adagrad and @bzbzbz are you able to confirm if the SQLite scanner functions as expected in another binding? Eg, JDBC, Python, node, etc

Mause commented 1 year ago

This should now be fixed in the latest DuckDB dev version