#odbc #database #sql


Write ODBC Applications in (mostly) safe Rust

117 releases (54 breaking)

0.55.0 Mar 16, 2023
0.54.2 Feb 9, 2023
0.53.0 Dec 20, 2022
0.52.3 Nov 28, 2022
0.10.3 Nov 21, 2020

#60 in Database interfaces

Download history 1049/week @ 2022-12-03 1309/week @ 2022-12-10 1134/week @ 2022-12-17 525/week @ 2022-12-24 814/week @ 2022-12-31 1097/week @ 2023-01-07 1209/week @ 2023-01-14 1102/week @ 2023-01-21 1149/week @ 2023-01-28 1082/week @ 2023-02-04 1536/week @ 2023-02-11 1661/week @ 2023-02-18 1177/week @ 2023-02-25 913/week @ 2023-03-04 1114/week @ 2023-03-11 1335/week @ 2023-03-18

4,694 downloads per month
Used in 12 crates (10 directly)

MIT license

6.5K SLoC


Docs Licence Crates.io Coverage Status

Rust ODBC bindings. ODBC (Open Database Connectivity) is an open standard to connect to a variaty of data sources. Most data sources offer ODBC drivers. This crate is currently tested against:

  • Microsoft SQL Server
  • PostgreSQL
  • MariaDB
  • SQLite

Current ODBC Version is 3.80.

This crate is build on top of the odbc-sys ffi bindings, which provide definitions of the ODBC C Interface, but do not build any kind of abstraction on top of it.


Check the guide for code examples and a tour of the features.


To build this library you need to link against the odbc library of your systems ODBC driver manager. It should be automatically detected by the build. On Windows systems it is preinstalled. On Linux and OS-X unix-odbc must be installed. To create a Connections to a data source, its ODBC driver must also be installed.


Nothing to do. ODBC driver manager is preinstalled.


sudo apt-get install unixodbc-dev

OS-X (intel)

You can use homebrew to install UnixODBC

brew install unixodbc


cargo build is not going to pick up libodbc.so installed via homebrew due to the fact that homebrew on ARM Mac installs into /opt/homebrew/Cellar as opposed to /usr/local/opt/.

You find documentation on what directories are searched during build here: https://doc.rust-lang.org/cargo/reference/environment-variables.html#dynamic-library-paths.

You can also install unixODBC from source:

  1. copy the unixODBC-2.3.9.tar.gz file somewhere you can create files and directories
  2. gunzip unixODBC*.tar.gz
  3. tar xvf unixODBC*.tar
  4. ./configure
  5. make
  6. make install


  • Connect using Data Source names (DSN)
  • Connect using ODBC connection strings
  • Connect using prompts (windows)
  • Log ODBC diagnostics and warnings (via log crate).
  • Columnar bulk inserts.
  • Columnar bulk queries.
  • Rowise bulk inserts.
  • Rowise bulk queries.
  • Output parameters of stored procedures.
  • prepared and 'one shot' queries.
  • Transactions
  • Pass parameters to queries
  • Asynchronous execution of one shot queries
  • Asynchronous execution of prepared queries
  • Asynchronous connecting to database
  • Asynchronous fetching of Metainformation
  • Multithreading
  • Inserting large binary / text data in stream
  • Fetching arbitrary large text / binary data in stream
  • Connection pooling
  • List tables of data sources


~142K SLoC