SQLite

The sq SQLite driver implements connectivity for the SQLite database. It makes use of the backing mattn/sqlite3 library. The driver implements all optional sq driver features.

Add source

Use sq add to add a source. The location argument is simply the filepath to the SQLite DB file. For example:

# Relative path
$ sq add ./sakila.db

# Absolute path
$ sq add /Users/neilotoole/sakila.db

sq usually can detect that a file is a SQLite datafile, but in the event it doesn’t, you can explicitly specify the driver type:

$ sq add --driver=sqlite3 ./sakila.db

Use the connection string form with prefix sqlite3:// to specify connection parameters .

$ sq add 'sqlite3://sakila.db?cache=shared&mode=rw'

The full set of supported parameters can be found in the mattn/sqlite3 docs .

Create new SQLite DB

You can use sq to create a new, empty, SQLite DB file.

$ sq add --driver sqlite3 hello.db
@hello  sqlite3  hello.db

Extensions

The SQLite driver has several extensions baked in.

ExtensionDetails
vtableVirtual Table
👉 sq inspect will show the virtual table’s type as virtual.
fts5Full Text Search 5
jsonJSON
math_functionsMath Functions
introspectAdditional PRAGMA statements: function_list, module_list, pragma_list
stat4Additional statistics to assist query planning

Inspect field provenance

sq inspect populates the fields below from SQLite pragmas, built-in functions, and the database file itself.

Source-level fields

FieldSource
nameDB file basename
schemafirst row of pragma_database_list (typically main)
cataloghardcoded default — SQLite has no catalog concept
usernot populated — SQLite has no user model
db_product"SQLite3 v" + db_version
db_versionsqlite_version()
sizefilesystem size of the DB file (os.Stat)

Per-table fields

FieldSource
row_countlive SELECT COUNT(*) FROM "tbl"
sizenot reported — SQLite does not expose per-table storage