Code for SQLite3 is a small macOS application that generates efficient Swift code to access SQLite3 databases. Interested in letting us write an app for you? Contact us!

Code for SQLite3 is a small macOS application that generates efficient Swift code to access SQLite3 databases. Interested in letting us write an app for you? Contact us!

“Code for SQLite3” is a little macOS application that accepts either SQLite3 database files or SQL source code, and generates Swift source code for them.

This is done for two main use cases: 1) To bundle and access resource data that is available as a SQLite database. 2) To generate highly efficient database access code, e.g. for caching offline-first data.

The app generates a Swift structure for the database and for each SQL table and view, plus accompanying, highly optimised, code. It can work either with the “Lighter” package or generate dependency free SQLite code.

The application requires macOS Monterey.
Try it out for free! Download the time and feature restricted demo version: Enlighter-Demo.app-v1.0.10-b10.zip.

Features

  • Produces extremely efficient low-level SQLite code that directly binds to SQLite w/o any runtime mapping and runs as fast as possible. Avoids copying data from Swift to C.
  • Can generate dependency free API wrappers, that directly use SQLite3 and nothing else. But still provide a reasonably convenient API.
  • Alternatively generates API that uses "Lighter", a tiny library to make the SQLite3 access type-safe
  • Completely type-safe, down to the SQLite3 schema! I.e. tables or columns that do not exist in the database, can't be used.
  • Rows can be filtered using Swift closures that directly run within SQLite
  • Generates extensive DocC documentation, which includes information on how to use the generated wrappers, the SQL that created an associated table, and more.
  • Supports both, tables and views. Views can be used to precreate named queries (e.g. complex joins or sum selects).
  • Can load from both, plain SQL source code and actual binary SQLite3 databases.
  • Generates accessors that can follow relationships formed by foreign keys.
  • Can synthesizes primary (and foreign) keys, even if they are not properly declared in the SQLite database.
  • Can generate Codable, Identifiable and Hashable models.
  • Can generate Swift 5.5 async/await APIs when used w/ the "Lighter" library.

Support

Looking for help with Code for SQLite3? Check out the: Support page.

Credit where credit is due!

SQLite3 - thanks for being available. One of the best software ever.

The app uses the nice Highlight.js to perform the syntax highlighting in the editors.