- A driver manager is required to manage communication between applications and the ODBC driver. DuckDB supports
unixODBC, which is a complete ODBC driver manager for macOS and Linux. Users can install it from the command line via Homebrew:
batch
brew install unixodbc
- DuckDB releases ODBC drivers for macOS on Apple Silicon (
arm64) and Intel (x86_64) CPUs. To download the driver for Apple Silicon, run:
batch
wget https://github.com/duckdb/duckdb-odbc/releases/download/v2.0.0.0/duckdb_odbc-macos-arm64.zip
To download the driver for Intel, run:
batch
wget https://github.com/duckdb/duckdb-odbc/releases/download/v2.0.0.0/duckdb_odbc-macos-amd64.zip
- The archive contains the
libduckdb_odbc.dylibartifact. To extract it to a directory, run (on Intel, replacearm64withamd64):
batch
mkdir duckdb_odbc && unzip duckdb_odbc-macos-arm64.zip -d duckdb_odbc
- There are two ways to configure the ODBC driver, either by initializing via the configuration files, or by connecting with
SQLDriverConnect. A combination of the two is also possible.
Furthermore, the ODBC driver supports all the configuration options included in DuckDB.
If a configuration is set in both the connection string passed to
SQLDriverConnectand in theodbc.inifile, the one passed toSQLDriverConnectwill take precedence.
For the details of the configuration parameters, see the ODBC configuration page.
- After the configuration, to validate the installation, it is possible to use an ODBC client. unixODBC uses a command line tool called
isql.
Use the DSN defined in odbc.ini as a parameter of isql.
batch
isql DuckDB
text
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| echo [string] |
| quit |
| |
+---------------------------------------+
sql
SQL> SELECT 42;
```text +------------+ | 42 | +------------+ | 42 | +------------+
SQLRowCount returns -1 1 rows fetched ```