Skip to content

lionelperrin/nanodbc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Synopsis

A very small C++ wrapper for the native C ODBC API. Please see the online documentation for user information, example usage, propaganda, and detailed source level documentation.

Building

You don't necessarily need to build nanodbc, as you can just drop the header and implementation files into your project. However I have provided CMake files which can be used to build a shared library object, or build and run the included unit tests. The CMake files will also support out of source builds.

Unit tests are built using Boost.Test and therefore require Boost be installed. In order to build the tests you will also need to have either unixODBC or iODBC installed and discoverable by CMake. This is easy on OS X (for example) where you can just use Homebrew to install unixODBC with brew install unixodbc, or simply use the system provided iODBC if you have OS X prior to 10.9. Also note that you can install Boost via Homebrew as well, which is very convenient!

Finally, the unit tests attempt to connect to a SQLite database, so you will have to have that and a SQLite ODBC driver installed. At the time of this writing, there happens to be a nice SQLite ODBC driver available from Christian Werner's website. The tests expect to find a data source named sqlite. So for example, your odbcinst.ini file on OS X might have a section similar to the following.

[sqlite]
Description             = SQLite ODBC Driver
Driver                  = /usr/lib/libsqlite3odbc-0.93.dylib
Setup                   = /usr/lib/libsqlite3odbc-0.93.dylib
Threading               = 2

Example Build Process

It's most convenient to create a build directory for an out of source build, but this isn't required. After you've used cmake to generate your Makefiles, you probably only really need to be aware of make nanodbc which will build your shared object, or make check which will build and run the unit tests. If the unit tests fail, you can run ctest --output-on-failure directly to get detailed output. You may also want to install nanodbc to your system using make install.

cd path/to/nanodbc/repository
mkdir build
cd build
cmake ..
make # creates shared library
make nanodbc # creates shared library
make example # builds example program
make tests # only builds the unit tests
make test # only runs the unit tests
make check # builds and then runs unit tests
ctest --output-on-failure # provide more details on unit test failures
make install # installs nanodbc.h and shared library

About

A very small C++ wrapper for the native C ODBC API.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 100.0%