The Database class encapsulates a single connection to a SQLite3 database. Its usage is very straightforward:

  require 'sqlite3'

  db = SQLite3::Database.new( "data.db" )

  db.execute( "select * from table" ) do |row|
    p row
  end

  db.close

It wraps the lower-level methods provides by the selected driver, and includes the Pragmas module for access to various pragma convenience methods.

The Database class provides type translation services as well, by which the SQLite3 data types (which are all represented as strings) may be converted into their corresponding types (as defined in the schemas for their tables). This translation only occurs when querying data from the database—insertions and updates are all still typeless.

Furthermore, the Database class has been designed to work well with the ArrayFields module from Ara Howard. If you require the ArrayFields module before performing a query, and if you have not enabled results as hashes, then the results will all be indexible by field name.

Methods
Included Modules