SQLite Database Access

SQLite Database Access

Max contains an implementation of the SQLite database engine (more info is available at http://sqlite.org. This database engine is accessible through both the C-API and directly in Max through the JavaScript interface. A tutorial on the Javascript interface written by Andrew Benson has been published on the Cycling '74 website.

The Javascript interface is composed of two objects: SQLite and SQLResult. A SQLResult object is used to represent the data returned by queries to the SQLite object. These objects are created in the same manner as any object in Javascript, as shown below.

var sqlite = new SQLite()
var result = new SQLResult()

SQLite Object Methods

open

Arguments

name [String]
ram-based [Boolean]

close

exec

Arguments

query string [String]
SQLResult object [String]

lastinsertid

starttransaction

endtransaction

SQLResult Object Methods

numrecords

numfields

fieldname

Arguments

column index [Number]

value

Arguments

column index [Number]
record index [Number]

All records returned by the SQLResult object are returned as strings. Thus, a numeric value such as 1 is actually returned as the string "1". SQLite only uses datatypes as recommendations. It does not enforce data types and in fact always returns a string. More information about this and other SQLite-specific topics can be found in a Google Talk given by Richard Hipp (the author of the SQLite library) at https://www.youtube.com/watch?v=jN_YdMdjVpU .

See Also

Name Description
JavaScript Usage JavaScript Usage