46 releases

Uses new Rust 2021

0.21.2 Feb 4, 2022
0.21.0 Jan 30, 2022
0.20.0 Oct 14, 2021
0.18.4 Jul 10, 2021
0.2.6 Mar 26, 2017

#5 in #odbc

Download history 1472/week @ 2022-04-24 1284/week @ 2022-05-01 1313/week @ 2022-05-08 2242/week @ 2022-05-15 1529/week @ 2022-05-22 1687/week @ 2022-05-29 2006/week @ 2022-06-05 1813/week @ 2022-06-12 1507/week @ 2022-06-19 1653/week @ 2022-06-26 1133/week @ 2022-07-03 1245/week @ 2022-07-10 1588/week @ 2022-07-17 1641/week @ 2022-07-24 1934/week @ 2022-07-31 1726/week @ 2022-08-07

6,960 downloads per month
Used in 20 crates (6 directly)

MIT license

84KB
1K SLoC

odbc-sys

Docs MIT licensed Published

FFI (Foreign Function Interface) bindings for ODBC (Open Database Connectivity) As ffi bindings to C-APIs are low level by nature this library is intended to be the foundation of other libraries to build on top, rather than to be used directly.

Design Goals

  • Providing declarations of ODBC Symbols compatible to the C-Interface of an ODBC Driver Manager
  • Provide correct definition of symbols for Unix and Windows in either 32Bit or 64Bit flavour
  • Not to abstract away any power of the underlying API
  • Increase type safety where feasable
  • As it is as of now unlikely to happen that anyone is writing ODBC 2.0 applications in Rust therefore deprecated symbols like 'SQLAllocEnv' have been left out intentionally.

Linking

This library will link against odbc32.dll (preinstalled) on Windows systems. On Linux and OS-X it links against libodbc.so by default. This is typically provided by unix-odbc. Using the --feature iodbc you can also link against libiodbc.so. This may be interessting if you are trying to connect to some older data sources on OS-X.

Installing unix-odbc

Linux

Use your systems packet manager to install unixodbc-dev. E.g. on Ubuntu / Debian

sudo apt install unixodbc-dev

OS-X

On Intel based architectures you can install unix-odbc using homebrew.

brew install unixodbc

Note for ARM based OS-X Systems (MAC M1):

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

Thanks to @TBPixel for testing this!

Windows

As windows does ship with ODBC preinstalled, you are good to go out of the box.

Current State

Symbols are added to this library as we go along implementing uses cases in higher level APIs. If you miss something please do not hesitate to contribute.

Documentation

Thanks to the folks of docs.rs for building and hosting the documentation!

Contributing

Want to help out? Just create an issue, pull request.

No runtime deps