Interested in improving this site? Please check the To Do page.

Back to Verbs

SQLite Verbs

. New verb.

SQLite implementation notes

As of 10/10/2006, SQLite is implemented within Frontier’s main branch, in Frontier version 10.1a11. – David Gewirtz

This section describes the Frontier-specific wrapper to the SQLite database engine. The following are some notes you should be aware of as you prepare to use SQLite within Frontier:

  • SQLite is embedded within the Frontier kernel. There are no external libraries you need to use.
  • The version of SQLite embedded within the Frontier Kernel is 3.3.7
  • Frontier implements a “Frontierified” version of SQLite, designed initially to provide large data storage capabilities natively within Frontier. Not all of the SQLite API has been implemented.
  • Function names have been “Frontierified” as well, to make them clearer for a Frontier developer. For example, the sqlite3_prepare function has been named sqlite.compileQuery in Frontier. The sqlite3_finalize function has been named sqlite.clearQuery in Frontier, and so forth. This has also been done to indicate that Frontier calls to SQLite are not direct one-to-one analogs to the SQLite API. Some adjustment to the data handling and operation has been done within Frontier.
  • Frontier supports a data interface for text, integer, and floating point numbers. Blob support has not been implemented.
  • SQLite operates on a base-0 structure, meaning that the first item in a given sequence is always considered 0. By contrast, Frontier operates on a base-1 structure, meaning that the first element in a Frontier sequence is always a 1. The Frontier wrapper to SQLite implements access as a base-1 structure. If you want the first column, you’ll specify column 1, not 0. Internally, Frontier converts from its own base-1 to base-0. This can be confusing if you’re reading SQLite documentation, so simply be aware that whenever SQLite talks about an offset, SQLite begins with 0 and Frontier with 1.
  • SQLite supports multiple SQL statements in SQL queries. The current Frontier implementation does not. For each query, Frontier’s wrapper to SQL will simply query based on the first statement in the SQL provided.
  • SQLite provides three different ways to perform queries. The Frontier wrapper implements only one of them. In the Frontier implementation, you’ll need to first compile a query, then step through your query results row-by-row, and then, finally, clear the query from memory. Obviously for SQL calls that only return one line of data or no data at all, you’ll only need to step through one row of query results to be sure the query executes. Frontier does implement sqlite.easyQuery, a script-based interface to the SQLite query engine that does everything in one call.
  • SQLite (and all SQL, for that matter) is very fussy about characters and character formatting. One utility function, sqlite.escapeQuotes has been provided to help with this, but you’ll need to be very careful about how you send strings into the SQLite interface and how you process them when they come back out. Pay particular attention to single and double quotes, and to the Frontier escape character, the backslash (\).
  • Although SQLite has a series of Unicode-smart functions, the Frontier SQLite wrapper does not. Frontier’s SQLite wrapper implements simple, seven-bit character values. Anything more may screw things up, so, again, use care.
  • While SQLite is reasonably thread-aware, it’s generally not good to pass database IDs across threads. See multi-threading for details.
  • The Frontier implementation of the SQLite wrapper requires you to do more management than is typical in Frontier. In particular, you’ll need to keep track of database IDs and be sure to close them when you exit Frontier and you’ll need to keep track of query IDs and be sure to clear them when you’re done or exit Frontier. Frontier will not implicitly do any SQLite garbage collection.
  • The Frontier implementation of the SQLite wrapper works on OSX as well as Windows, but the Mac implementation is a bit convoluted. SQLite requires POSIX-based filenames passed to sqlite.open, so you’re likely to have to do some string conversion to make it work.

Resources


Personal Tools