d2sqlite3

D2SQLite3 provides a thin and convenient wrapper around the SQLite C API.

Features:

  • Use reference-counted structs (Database, Statement) instead of SQLite objects pointers.
  • Run multistatement SQL code with Database.run().
  • Use built-in integral types, floating point types, string, immutable(ubyte)[] and Nullable types directly: conversions to and from SQLite types is automatic and GC-safe.
  • Bind multiple values to a prepare statement with Statement.bindAll() or Statement.inject(). It's also possible to bind the fields of a struct automatically with Statement.inject().
  • Handle the results of a query as a range of Rows, and the columns of a row as a range of ColumnData (equivalent of a Variant fit for SQLite types).
  • Access the data in a result row directly, by index or by name, with the Row.peek!T() methods.
  • Make a struct out of the data of a row with Row.as!T().
  • Register D functions as SQLite callbacks, with Database.setUpdateHook() et al.
  • Create new SQLite functions, aggregates or collations out of D functions or delegate, with automatic type converions, with Database.createFunction() et al.
  • Store all the rows and columns resulting from a query at once with the cached function (sometimes useful even if not memory-friendly...).
  • Use an unlock notification when two or more connections access the same database in shared-cache mode, either using SQLite's dedicated API (sqlite_unlock_notify) or using an emulated equivalent.

Modules

database
module d2sqlite3.database

Managing SQLite3 database connections.

library
module d2sqlite3.library

Miscellaneous SQLite3 library functions.

results
module d2sqlite3.results

Managing query results.

sqlite3
module d2sqlite3.sqlite3

Auto-generated C API bindings.

statement
module d2sqlite3.statement

Managing prepared statements.

Public Imports

d2sqlite3.library
public import d2sqlite3.library;
d2sqlite3.database
public import d2sqlite3.database;
d2sqlite3.statement
public import d2sqlite3.statement;
d2sqlite3.results
public import d2sqlite3.results;
d2sqlite3.sqlite3
public import d2sqlite3.sqlite3;

Meta

Authors

Nicolas Sicard (biozic) and other contributors at https://github.com/biozic/d2sqlite3