Skip to content

basemodo db

Run SQL against an App's SQLite database (/data/app.db) and print the rows.

Terminal window
basemodo db [OPTIONS] [SQL]

Every App has a SQLite file at /data/app.db on its volume ($BASEMODO_DB in its processes), made by whatever opens it first. Several statements run in order and stop at the first error; what ran before it stays done. The rows are those of the last statement that returned any. A sleeping App is woken to run it. In a terminal the SQL may come on stdin.

Arguments

  • SQL: The SQL to run; - or nothing reads it from stdin.
  • --app <APP>: The App whose database to use. Default: the one named after the current folder.

Like every command, it also takes the global options --json and --api-url.

Examples

Look at the latest rows of a table:

Terminal window
basemodo db "select * from tasks order by id desc limit 10"

List the tables:

Terminal window
basemodo db "select name from sqlite_master where type = 'table'"

Run a file of SQL against another App:

Terminal window
basemodo db --app lunch-rota < fix.sql

Output

With --json, it prints {"columns": [...], "rows": [[...], ...]}, empty for statements that return no rows. SQL that fails is an error with code sql_error and SQLite's message.

From an agent

The local MCP serves it as the tool db. It changes things, so an agent's client may ask you before it runs. Its arguments are the command's, named as JSON keys: sql (text), app (text). It answers what the command prints with --json.

Explained in