In version 0.13.0 a new C API (Application Programming Interface) has been introduced. It is intended to be a stable, public API used in C and C++ programs as well as to be a basis of development of libraries for other languages.


The new API is inspired by sqlite3 API. It consists of a set of C functions and constants defined in header file odbql.h.

Adoption of the design of sqlite3 API, a simple and mature pure C API of the very popular public domain SQL database, addressed several issues in the design of the old C++, C and Fortran APIs used in applications developed at ECMWF before public release of ODB API:

  • The old C API that was developed to wrap C++ API - mainly in order to provide an interface for Fortran programs - didn't work as intended when dealing with heterogeneous files, see ODB-232, and fixing it required changes to the API, which would break existing applications and disrupt their development.
  • The API for defining metadata of files was inconvenient and inflexible. We now fully adopt a more SQL-like way of defining metadata, using DDL (Data Definition Language), a subset of SQL (CREATE TABLE statement). This is both more practical and flexible - for example we will not need to introduce new API functions or constants when we need to add a new data type to SQL.
  • Adopting design of the ubiquitous sqlite3 should make it easier to develop libraries for languages that already have libraries for sqlite3.

Generally, the ODB API functions that are part of public interface start with odbql_ prefix. All of them have an equivalent in the public interface of sqlite3 that has a sqlite3_ prefix and a similar syntax (parameters) and semantics.

Similarly, most status and error codes, as well as numerical codes denoting column types, defined in odbql.h with macros prefixed with ODBQL_, have an equivalent macro in sqlite3 that starts with SQLITE_ and has the same meaning and numerical value. However, due to differences between ODB API and sqlite3 it was necessary to add some ODB API specific status codes, at this time these are ODBQL_METADATA_CHANGED and ODBQL_BITFIELD (an ODB specific data type).

See C/C++ examples for complete examples of how to read, write and process data with ODB API SQL engine using ODB API C/C++ interface.

Fortran API

Fortran ODB API is a set of Fortran 95 subroutines and functions wrapping the C API described above. The subroutines and functions are in a module odbql_wrappers, and have the same names as their C equivalents.

See file Fortran examples for example programs using module odbql_wrappers.

Python API

Python interface of ODB API implements PEP 249 -- Python Database API Specification v2.0.

See Python examples for example code using the module.