A DuckDB extension to read data directly from databases supporting the ODBC interface
ODBCSYSINI=${PWD} ODBCINSTINI=.odbcinst.ini ODBCINI=.odbc.ini ./build/release/duckdb
D select * from odbc_scan(
'Driver={db2 odbctest};Hostname=localhost;Database=odbctest;Uid=db2inst1;Pwd=password;Port=50000',
'DB2INST1',
'PEOPLE'
);
┌──────────────┬───────┬───────────────┐
│ NAME │ AGE │ SALARY │
│ varchar │ int32 │ decimal(20,2) │
├──────────────┼───────┼───────────────┤
│ Lebron James │ 37 │ 100.10 │
│ Spiderman │ 25 │ 200.20 │
│ Wonder Woman │ 22 │ 300.30 │
│ David Bowie │ 69 │ 400.40 │
└──────────────┴───────┴───────────────┘
This extension is tested and known to work with the ODBC drivers of the following databases.
Database | Tests | Linux x86_64 | Linux arm64 | OS X x86_64 | OS X aarch64 |
---|---|---|---|---|---|
IBM Db2 | odbc_scan_db2 | [x] |
[ ] |
[x] |
[ ] |
MSSQL | odbc_scan_msql | [ ] |
[ ] |
[ ] |
[ ] |
Oracle | odbc_scan_oracle | [ ] |
[ ] |
[ ] |
[ ] |
Postgres | odbc_scan_postgres | [x] |
[x] |
[x] |
[x] |
MySQL | odbc_scan_mysql | [ ] |
[ ] |
[ ] |
[ ] |
MariaDB | odbc_scan_mariadb | [ ] |
[ ] |
[ ] |
[ ] |
Snowflake | odbc_scan_snowflake | [ ] |
[ ] |
[ ] |
[ ] |
BigQuery | odbc_scan_big_query | [ ] |
[ ] |
[ ] |
[ ] |
MongoDB | odbc_scan_mongo_db | [ ] |
[ ] |
[ ] |
[ ] |
If you have tested the extension against other databases let us know by opening an issue or creating a pull request with a set of tests.
For a full list of supported values read the connection string documentation.
Drivers can be downloaded from most vendors. This package manages ODBC drivers through the odbc-drivers-nix flake. If you'd like to have nix download and manage drivers and their dependencies follow the instructions in the README.
This repository manages development dependencies such drivers and shared libraries with nix. It assumes you have it installed.
All development
and test
tasks should be run within a nix shell
nix develop -c $SHELL
The odbc-scanner-duckdb-extension
is built with a clang
toolchain. To enable clangd
LSP support run the .clangd
generator nix application.
nix run .#generate-dot-clangd
To build the extension with the official DuckDB cmake
toolchain and clangd
run the build nix application which will link
to the correct version of unixodbc
.
nix run .#build
./build/release/duckdb
To use ODBC DSN's with driver paths managed by the odbc-drivers-nix
flake run the generate nix apps.
nix run .#generate-odbc-ini
nix run .#generate-odbcinst-ini