Limitations
Windows Support
Duckdb is not supported on Windows 1, as a result the feature is locked behind the "duckdb" feature flag.
1
I'm not sure why, PR's welcome, GDB returns the following (seems like a .dll issue):
gdb .\extract_to_sqlite_rs.exe
run
bt
During startup program exited with code `0xc0000135`
I have tried:
winget install DuckDB.cli
scoop install duckdb
However, it did not help
SQLite Types
I've had some issues with the NUMERIC type in SQLite, this causes Rusqlite to pass an error up to Connector-X like so:
#![allow(unused)] fn main() { called `Result::unwrap()` on an `Err` value: ArrowError( SQLiteArrowTransportError( Source( SQLiteError( InvalidColumnType( 7, "latitude", Real))))) }
To overcome this create a new table with the same data:
-- Step 1: Create a new table with the desired REAL type
CREATE TABLE new_notes_test (
id TEXT PRIMARY KEY,
latitude NUMERIC
);
-- Step 2: Copy data from the old table to the new table
INSERT INTO new_notes_test (id, value)
SELECT id, latitude
FROM notes;
From here one may:
-
Keep the New Table
-- Step 3: Drop the old table DROP TABLE notes; -- Step 4: Rename the new table to the original table name ALTER TABLE new_notes_test RENAME TO notes; -
Keep the Old Table
DROP TABLE new_notes_test -
Keep Both Tables
Keep second table with a different type to preserve all previous behaviour but allow exporting with this tool.
This requires a few triggers:
-
Insert Trigger
CREATE TRIGGER insert_trigger AFTER INSERT ON ExampleTable BEGIN INSERT INTO NewExampleTable (id, value) VALUES (NEW.id, NEW.value); END; -
Update Trigger
CREATE TRIGGER update_trigger AFTER UPDATE ON ExampleTable BEGIN UPDATE NewExampleTable SET value = NEW.value WHERE id = OLD.id; END; -
Read Trigger
CREATE TRIGGER delete_trigger AFTER DELETE ON ExampleTable BEGIN DELETE FROM NewExampleTable WHERE id = OLD.id; END;
-