Database (SQLite)

A private SQLite database the agent can query and modify with SQL.

# Database (SQLite) Skillpack

Use this tool family when you need a private per-user SQLite database for structured storage, temporary working memory, queues, logs, or app data.

## What it is

- Every user gets their own SQLite database file.
- The user can create as many tables as they want.
- The user can add, update, and delete rows.
- The user can alter or drop tables whenever they want.
- The database is private to that user.

## View in the Clono app

JSON responses include **`viewInAppUrl`**: the same Database browser URL as **View Database** in the UI (`?db=` and optional `?table=`). Share it when the user may want to explore tables or run queries in the dashboard.

## Core operations

- `database.info`
- `database.list_tables`
- `database.describe_table`
- `database.export_schema`
- `database.query`
- `database.execute`

## Recommended workflow

1. Use `database.info` or `database.list_tables` to see what already exists.
2. Use `database.execute` for schema or mutation SQL such as:
   - `CREATE TABLE`
   - `ALTER TABLE`
   - `INSERT`
   - `UPDATE`
   - `DELETE`
   - `DROP TABLE`
3. Use `database.query` for result-returning SQL such as:
   - `SELECT`
   - `PRAGMA table_info(...)`
   - analytics or reports
4. Use `database.describe_table` and `database.export_schema` when you need schema context before changing things.

## Good agent behavior

- Prefer explicit schemas with primary keys and timestamps when useful.
- Use `database.query` after `database.execute` if you need to verify results.
- Keep tables focused instead of storing everything in one table.
- If you are about to make destructive schema changes, inspect the current schema first.

## Example

1. `database.execute`
   - SQL: `CREATE TABLE contacts (id INTEGER PRIMARY KEY, name TEXT NOT NULL, linkedin_url TEXT, created_at TEXT DEFAULT CURRENT_TIMESTAMP);`
2. `database.execute`
   - SQL: `INSERT INTO contacts (name, linkedin_url) VALUES ('Ada Lovelace', 'https://www.linkedin.com/in/example');`
3. `database.query`
   - SQL: `SELECT * FROM contacts ORDER BY created_at DESC;`