On this page:
DB:   Database Connectivity
7.9.0.4

DB: Database Connectivity

Ryan Culpepper <ryanc@racket-lang.org>

A database interface for functional programmers.

 (require db) package: db-lib

This library provides a high-level interface to several database systems. The following database systems are currently supported:
  • PostgreSQL versions 7.4 and later. This library implements the PostgreSQL wire protocol, so no native client library is required.

  • MySQL versions 5 and later. This library implements the MySQL wire protocol, so no native client library is required.

  • SQLite version 3. The SQLite native client library is required; see SQLite Requirements.

  • Cassandra versions 2.1.0 and later. This library implements the Cassandra wire protocol (v3), so no native client is required.

  • ODBC. An ODBC Driver Manager and appropriate ODBC drivers are required; see ODBC Requirements. The following database systems are known to work with this library via ODBC (see ODBC Status for details): DB2, Oracle, and SQL Server.

The query operations are functional in spirit: queries return results or raise exceptions rather than stashing their state into a cursor object for later navigation and retrieval. Query parameters and result fields are automatically translated to and from appropriate Racket values. Resources are managed automatically by the garbage collector and via custodians. Connections are internally synchronized, so multiple threads can use a connection simultaneously.

Acknowledgments Thanks to Dave Gurnell, Noel Welsh, Mike Burns, and Doug Orleans for contributions to spgsql, the PostgreSQL-only predecessor of this library. The SQLite support is based in part on code from Jay McCarthy’s sqlite package.