Main Page | Class Hierarchy | Compound List | Compound Members | Related Pages

sqlite - Bindings for SQLite for D

This is a binding for the SQLite library for D. It supports both bindings to the normal C interface and a wrapper class named SQLite.

Downloads are available at the Downloads and Changelog page.

To compile the library you'll need dig. Call "make" to install. To use the library, you need to import it using:

 import net.BurtonRadons.sqlite.main;

digc will then pick up the library automatically as always.

I'll now give a short tutorial on the SQLite class. You first open up a connection to a database or create a new one using the constructor:

 SQLite.Database database = ("database.db");

Let's now create a sample table that has a couple columns.

 SQLite.Table table;

 if (database.tableExists ("sample"))
     table = database.table ("sample");
 else with (table = database.createTable ("sample"))
     // Create a column named "a"
     createColumn ("a");

     // We want to specify more parameters, so use this function instead.
     with (createColumn ("b"))
         // If an insert doesn't give a value for this column, this value will be used instead.
         defaultValue ("foobar");

     // Now register the table in the database.
     flush ();

We can then insert lines into the table:

 table.insert ("firstColumn", "secondColumn");

 char [] [char []] columns;

 columns ["a"] = "firstColumn";
 table.insert (columns);
 // This insertion puts "foobar" in the second column.

Binary data can be inserted and extracted; you don't need to do any processing to use data with the insert method or using queries. For other commands you can use the SQLite.quote () and SQLite.unquote () functions.

To retrieve values from a table, you use select. Because of the complexity of the command, trying to represent it in API form would either be far more verbose than a direct call or less capable, and certainly not as legible once you're used to the syntax.

Here is a basic SELECT call that will print out the columnated results:

 database.query ("SELECT * FROM sample").print ();

This will take a Query matrix and print out a table showing the results. You can find a rough-hewn specification of the SELECT command in the SQLite documentation.

CREATE INDEX is not directly supported.

CREATE TRIGGER is not directly supported.

CREATE VIEW is not directly supported.

UPDATE is not directly supported.

Not all error responses from exec are supported.

The "throw new Error" calls should be switched to use a named error and be documented as such.

The assert calls should be switched to use a named error and be documented as such.

Aggregate user-defined functions aren't supported. Use standard deviation as a sample when done.

SELECT should be documented.

Generated on Thu Jul 31 12:38:09 2003 for sqlite by doxygen 1.3.2