Skip to main content
@archildata/sqlite creates and queries SQLite databases stored on an Archil disk, with no database server to run. A disk can hold any number of databases, and many clients can use the same database at once, including for writes. This suits AI agents that keep their context as a mix of structured and unstructured data. Queries run with serverless execution in regions with compute. Each query counts as one serverless tool call, with execution included; see Pricing & Billing.

Setup

The package uses the disk SDK’s default client, configured from ARCHIL_API_KEY and ARCHIL_REGION or with archil.configure().

Create and open databases

A database is a file on the disk, addressed by its path. createDatabase creates the file if it doesn’t exist and opens it; getDatabase opens an existing one.

Run queries

Write queries as tagged templates. Values you interpolate are passed as parameters. Use read for queries that only read and write for queries that change data, including RETURNING queries. Finish a query with get() for one row, all() for every row, or run() for the write result (changes and lastInsertRowid).
write queries need exclusive access to the database file, while many read queries run in parallel.

Transactions

transaction runs several queries in one transaction: either all of them apply or none do.

Options

createDatabase and getDatabase take an options object as their third argument: Failed queries throw ArchilSQLiteError.