SQLite & Numbers
sqlite-logo

SQLite is an in-process library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. The code for SQLite is in the public domain and is thus free for use for any purpose, commercial or private. Its robust flexibility makes it a favorite database tool for businesses. And best of all, SQLite is a default component of OS X, ready to be used for your data-storage needs.

In addition to providing built-in support for SQLite, OS X also includes the Database Events application, an AppleScript interface for building and querying SQLite database files. Using the Database Events application and AppleScript you can easily transfer data between Numbers spreadsheets and SQLite databases!

The Database Events Dictionary

The scripting dictionary for Database Events is a simple but powerful scripting interface that includes all the elements necessary for creating and querying SQLite database files. It contains three classes: databases, records, and fields

database [inh. item ]: A collection of records, residing at a location in the file system.

elements

contains records; contained by application.

properties

locationalias , r/o ) : The folder that contains the database.

nametext, r/o ) : The name of the database.

responds to

close, make, save.

field [inh. item ]: A named piece of data, residing in a record.

elements

contained by records.

properties

idinteger , r/o ) : The unique id of the field.

nametext, r/o ) : The name of the field.

valueany ) : The value of the field.

responds to

delete, exists, make.

record [inh. item ]: A collection of fields, residing in a database.

elements

contains fields; contained by databases.

properties

idinteger , r/o ) : The unique id of the record.

nametext, r/o ) : The name of the record, equivalent to the value of the field named “name”.

responds to

delete, exists, make.

Using these classes you can use AppleScript statements to query SQLite database files, like this:

This section provides script examples for creating SQLite databases from Numbers tables, and for creating Numbers tables using the data in SQLite databases.

TOP | CONTINUE