Skip to main content

ODBC: Open Database Connectivity

ODBC (Open Database Connectivity) is a low-level, high-performance interface that is designed specifically for relational data stores as a standard way to connect to, and interact with a database.

Spice supports ODBC clients through an ODBC driver implementation based on the Flight SQL protocol. This enables ODBC-compatible applications to connect to Spice, execute queries, and retrieve data.

Limitations
  1. ODBC support is currently in alpha, and not all functionality is supported
  2. The Arrow Flight SQL ODBC driver is not available for 32-bit Windows versions
  3. The Arrow Flight SQL ODBC driver is not supported on the Apple ARM architecture

Install and configure the Flight SQL ODBC driver​

Download and install the Flight SQL ODBC driver​

Configure Flight SQL ODBC driver​

  • Open Start Menu -> Windows Administrative Tools -> click ODBC Data Sources (64-bit)
  • In the ODBC Data Source Administrator (64-bit) dialog, click System DSN
ODBC Data Source Administrator

ODBC Connection Parameters​

NameTypeDescription
hoststringThe IP address or hostname for the Spice runtime.
portintegerThe Spice runtime Arrow Flight endpoint port number
useEncryptionintegerConfigures the driver to use an SSL-encrypted connection. Accepted values: true (default) - The client communicates with the Spice runtime only using SSL encryption and false - SSL encryption is disabled.
disableCertificateVerificationintegerSpecifies whether the driver should verify the host certificate against the trust store. Default is false
useSystemTrustStoreintegerControls whether to use a CA certificate from the system's trust store, or from a specified .pem file. If true - The driver verifies the connection using a certificate in the system trust store. IF false - The driver verifies the connection using the .pem file specified by the trustedCerts parameter. true on Windows and macOS, false on Linux by default
trustedCertsstringThe full path of the .pem file containing certificates trusted by a CA, for the purpose of verifying the server. If this option is not set, then the driver defaults to using the trusted CA certificates .pem file installed by the driver.
note

The ODBC driver for Arrow Flight SQL does not support password-protected .pem/.crt files or multiple .crt certificates in a single .pem/.crt file.

Execute Test Query​

Ensure Spice runtime has started:

spiced --flight 0.0.0.0:50051
2024-10-06T20:06:50.084017Z  INFO runtime::opentelemetry: Spice Runtime OpenTelemetry listening on 127.0.0.1:50052
2024-10-06T20:06:50.084015Z INFO runtime::flight: Spice Runtime Flight listening on 0.0.0.0:50051
2024-10-06T20:06:50.086948Z INFO runtime::http: Spice Runtime HTTP listening on 127.0.0.1:8090
2024-10-06T20:06:50.297512Z INFO runtime: Initialized results cache; max size: 128.00 MiB, item ttl: 1s
2024-10-06T20:06:50.308775Z INFO runtime: Tool [document_similarity] ready to use
2024-10-06T20:06:50.308803Z INFO runtime: Tool [table_schema] ready to use
2024-10-06T20:06:50.308814Z INFO runtime: Tool [sql] ready to use
2024-10-06T20:06:50.308829Z INFO runtime: Tool [list_datasets] ready to use
2024-10-06T20:06:50.921420Z INFO runtime: Dataset taxi_trips registered (s3://spiceai-demo-datasets/taxi_trips/2024/), results cache enabled.

Configure the client app to use Arrow Flight SQL ODBC Driver.

Example ODBC Client Configuration

Run a sample query, such as

SELECT trip_distance, total_amount FROM taxi_trips ORDER BY trip_distance DESC LIMIT 10;
Example Query Results