Database tools
Query MySQL, ClickHouse and SQLite with schema awareness and safety guardrails.
@elyracode/db-tools lets the agent answer questions about your real data without leaving the terminal. Connections are read from your project’s .env automatically, and writes are blocked by default.
Install
elyra install npm:@elyracode/db-tools
Tools
| Tool | Description |
|---|---|
query_mysql |
Execute SQL against MySQL. Results returned as JSON. |
query_clickhouse |
Execute SQL against ClickHouse. Optimized for analytical queries on large datasets. |
query_sqlite |
Execute SQL against SQLite. Auto‑detects Laravel SQLite databases from .env. |
get_database_schema |
Discover tables, columns, types, and indexes. Supports MySQL, ClickHouse, and SQLite. |
Configuration
Automatic — .env (recommended)
If your project has a .env file (e.g. Laravel), db‑tools maps standard keys automatically:
.env key |
Maps to | Used by |
|---|---|---|
DB_HOST |
ELYRA_MYSQL_HOST |
MySQL |
DB_PORT |
ELYRA_MYSQL_PORT |
MySQL |
DB_DATABASE |
ELYRA_MYSQL_DATABASE |
MySQL |
DB_USERNAME |
ELYRA_MYSQL_USER |
MySQL |
DB_PASSWORD |
ELYRA_MYSQL_PASSWORD |
MySQL |
CLICKHOUSE_HOST |
ELYRA_CLICKHOUSE_HOST |
ClickHouse |
CLICKHOUSE_PORT |
ELYRA_CLICKHOUSE_PORT |
ClickHouse |
CLICKHOUSE_DATABASE |
ELYRA_CLICKHOUSE_DATABASE |
ClickHouse |
CLICKHOUSE_USERNAME |
ELYRA_CLICKHOUSE_USERNAME |
ClickHouse |
CLICKHOUSE_PASSWORD |
ELYRA_CLICKHOUSE_PASSWORD |
ClickHouse |
CLICKHOUSE_HTTPS |
ELYRA_CLICKHOUSE_HTTPS |
ClickHouse |
Manual — environment variables
ELYRA_* env vars always take precedence over .env:
# MySQL
export ELYRA_MYSQL_HOST=localhost
export ELYRA_MYSQL_PORT=3306
export ELYRA_MYSQL_USER=readonly_user
export ELYRA_MYSQL_PASSWORD=secret
export ELYRA_MYSQL_DATABASE=myapp
# ClickHouse
export ELYRA_CLICKHOUSE_HOST=localhost
export ELYRA_CLICKHOUSE_PORT=8123
export ELYRA_CLICKHOUSE_DATABASE=mydb
export ELYRA_CLICKHOUSE_USERNAME=default
export ELYRA_CLICKHOUSE_PASSWORD=secret
SQLite
SQLite is auto‑detected:
- If
.envhasDB_CONNECTION=sqlite, the path fromDB_DATABASEis used. - Falls back to
database/database.sqlite(Laravel default). - Or pass an explicit
db_pathper call.
Security
- Read‑only by default — only
SELECT,SHOW,DESCRIBE,EXPLAINare permitted. - Writes — set
ELYRA_DB_ALLOW_WRITES=trueto enableINSERT,UPDATE,DELETE. - Recommendation — connect with a database user that only has
SELECT.
Examples
> How many users registered this week?
> Show me the top 10 products by revenue
> What's the average response time from the logs table?
> Describe the schema of the orders table
The agent calls get_database_schema first to understand structure, then writes and runs the SQL.