Small, auditable SQLcl runner for Oracle Database projects.
sql-runner runs project SQL scripts through saved SQLcl connections, writes structured logs under logs/<env>/runs, extracts an INTENT block from each script, and indexes run history into SQLite when sqlite3 is available.
The log files are the source of truth. The SQLite database is only a rebuildable query surface.
- Bash
- Oracle SQLcl available as
sqlonPATH sqlite3for searchable run historygitfor commit and dirty-worktree metadatashellcheckfor optional linting
Create or confirm a saved SQLcl connection:
sql /nolog
conn -save my_user/my_password@example_high -name my_app_dev
exitCopy the example connection map and edit it:
cp config/connections.conf.example config/connections.confExample config/connections.conf:
admin=admin
dev=my_app_dev
test=my_app_test
prod=my_app_prod
Run the smoke test:
bin/run-sql.sh --env dev --script examples/verify-connection.sqlUse debug mode when you want SQLcl output mirrored to the terminal:
bin/run-sql.sh --env dev --script examples/verify-connection.sql --log-level debugReview recent history:
bin/db-history-recent.sh dev 5By default, bin/run-sql.sh reads:
config/connections.conf
Each non-comment line maps a logical environment to a saved SQLcl connection:
dev=my_saved_sqlcl_connection
Use a different config file with:
SQL_RUNNER_CONFIG=/path/to/connections.conf bin/run-sql.sh --env dev --script examples/verify-connection.sqlconfig/connections.conf is ignored by git. Publish only config/connections.conf.example.
bin/run-sql.sh --env <name> --script <file.sql> [--log-level normal|debug]Production execution is guarded:
ALLOW_PROD_SQL=yes bin/run-sql.sh --env prod --script deploy/create/00_full.sqlThe runner configures SQLcl with:
whenever oserror exit failure rollbackwhenever sqlerror exit sql.sqlcode rollbackset serveroutput on size unlimitedset define offset sqlblanklines on
After the script runs, it queries USER_ERRORS so compile errors are captured in the same log.
Put an intent block near the top of SQL scripts:
-- INTENT:
-- Purpose: Add customer preference storage.
-- Approach: Create CUSTOMER_PREFS rather than extending CUSTOMER.
-- Reason: Preferences evolve independently.
-- Expected objects:
-- CUSTOMER_PREFS
-- CUSTOMER_PREFS_PK
-- Risk: Low
-- Prior history checked: None found.
-- END INTENTThe block is copied into the run log and SQLite history record.
Every run writes a structured log:
logs/<env>/runs/<run_id>.log
The log contains:
[INFO]: run id, environment, connection, script path, script hash, git commit, dirty-worktree flag, timestamp[INTENT]: extracted intent block[ACTION]: SQLcl output[OUTCOME]: success/failure and SQLcl exit code
Do not commit logs/.
Initialize or rebuild the SQLite index:
bin/db-history-init.sh --schema-only
bin/db-history-init.sh --rebuildQuery recent runs:
bin/db-history-recent.sh [env] [limit]Find failures:
bin/db-history-failures.sh [term]Search by description using FTS5 when available:
bin/db-history-similar.sh "package compile failure"Search by script, path, intent, or summary:
bin/db-history-script.sh package_name [limit]Search by git commit prefix:
bin/db-history-commit.sh abc1234 [limit]Show a full run record:
bin/db-history-show.sh <run_id-or-prefix>road-secrets generates, stores and applies passwords for ROAD development and test environments. Nobody needs to choose or remember one. It also stores API keys for outside services. It keeps each password in the macOS login keychain and keeps the copies up to date: the database user's SQLcl saved connections, or a road-kit app's config/local.env. It refuses anything for production. The full design is in spec/road-secrets-spec-v1.md.
It is a per-user tool for macOS, installed once per Mac. It is not copied into projects.
bin/install-road-secrets.shThis builds the Swift package in tools/road-secrets, installs the binary at ~/.local/bin/road-secrets and checks the login keychain. The build records its commit and time, so road-secrets --version shows which build is installed, for example road-secrets 1.9.0 (d5cb8ee, built 2026-11-28T23:20Z). make road-secrets-release makes the same build without installing it. A plain swift build reports (unknown commit, dev build). It needs Swift (xcode-select --install) and a road-atlas checkout at ~/Projects/road-atlas, or wherever ROAD_ATLAS points.
Every rebuild gives the binary a new identity. Afterwards, the first read of each Keychain item shows an "Always Allow" prompt on the Mac's screen. Click it once per item, and do not rebuild just before leaving an unattended run.
Keys look like road/<app>/<env>/<db|principal>/<NAME>:
road/road-kit/dev/principal/ADMIN a road-kit scaffold login
road/roadkitdb/dev/db/ADMIN ADMIN of a database that serves no production
road/livehub/dev/db/LIVEHUB_DEPLOY a database user, with every saved connection that logs in as it
road/shared/dev/apikey/OPENAI an API key that no single app owns
Every everyday command takes one argument: the key, exactly as list prints it. The commands work from any folder.
| Command | What it does |
|---|---|
road-secrets list [prefix] [--all] |
Lists keys. Never shows passwords. |
road-secrets add --app <app> --env <env> --kind <db|principal|apikey> --name <NAME> [details] |
Creates a new entry and sets its first password, or stores an API key |
road-secrets set <key> |
Generates a new password and applies it everywhere |
road-secrets sync <key> |
Pushes the Keychain password into every copy |
road-secrets get <key> |
Prints the password, for scripts |
road-secrets copy <key> |
Puts the password on the clipboard, marked concealed so clipboard managers do not keep it |
road-secrets check <key> |
Proves the stored password works |
road-secrets delete <key> [--yes] |
Removes the entry. Changes nothing else. |
road-secrets --version |
Shows the version, the commit it was built from and when |
add never asks a question, and it prints the new key when it succeeds. --kind is required.
To add a database user, give one saved connection that logs in as it, the wallet and the TNS name. Then do one of these:
- Give the user's current password on standard input. At a terminal, you are prompted and your typing is hidden. If you pipe it in, nothing is printed.
- Use
--via-admin, once the database's ADMIN entry exists.
pbpaste | road-secrets add --app roadkitdb --env dev --kind db --name ADMIN \
--connection roadkit_admin --wallet ~/wallets/roadkitdb.zip --tns roadkitdb_mediumroad-secrets add --app livehub --env dev --kind db --name LIVEHUB_DEPLOY --via-admin --yes \
--connection livehub_av_acc --wallet ~/wallets/roadkitdb.zip --tns roadkitdb_mediumThe password changes once, and every saved connection that logs in as that user is re-saved, proxy logins included. When there is more than one, pass --yes. Later, road-secrets set <key> rotates it, with everything else taken from the entry. set asks before re-saving several connections when you are at a terminal. Otherwise it needs --yes. Run it in a desktop session on the Mac, not over SSH.
To add a road-kit principal, use road-secrets add --app road-kit --env dev --kind principal --name ADMIN. The app's folder is $ROAD_PROJECTS/<app>, or ~/Projects/<app> if ROAD_PROJECTS is unset. Pass --project <path> if it is elsewhere. The folder is stored, so later commands find it from anywhere.
To store an API key, pipe it in, or run the command at a terminal and paste it at the hidden prompt. The value is never an argument, nothing is echoed, and one trailing newline is removed. --note is optional and is stored beside the key, never in it.
pbpaste | road-secrets add --app shared --env dev --kind apikey --name OPENAI --note "OpenAI, project road-dev"To replace a key after the service has issued a new one, use pbpaste | road-secrets set road/shared/dev/apikey/OPENAI. The tool never generates or rotates API keys itself, and check and sync have nothing to do for them. get, copy, list and delete work as for passwords.
API keys may be live production keys, and --env prod is allowed for them. Unlike passwords, they are not limited to dev and test. Any program running as you can read them, and so can Claude Code, unattended and with no approval prompt. Give every stored key only the permissions it needs, and set a spending cap wherever the service offers one.
list prints one line per entry, key<TAB>date<TAB>label, for every kind. ClipGrid's password panel reads that output, so its format is kept stable.
set, sync and check on a key that does not exist exit 3 and show the add command to use. add on a key that exists exits 2 and points to set.
Add these rules to the ask list in ~/.claude/settings.json. That file applies to every project, and the Code tab of the Claude desktop app reads it too. Claude Code then asks before running a script as ADMIN, or before reading an ADMIN password.
{
"permissions": {
"ask": [
"Bash(bin/run-sql.sh --env admin *)",
"Bash(./bin/run-sql.sh --env admin *)",
"Bash(road-secrets get *ADMIN)",
"Bash(road-secrets copy *ADMIN)",
"Bash(*/road-secrets get *ADMIN)",
"Bash(*/road-secrets copy *ADMIN)"
]
}
}These rules are a prompt, not a security boundary. The same program can be called in forms they do not match.
Offline tests do not require Oracle Database:
make testThis runs shell syntax checks, ShellCheck when installed, SQLite schema creation, fixture log rebuild, and basic runner validation paths.
road-secrets unit tests, which need Swift but no database or Keychain:
make road-secrets-testLive smoke test:
bin/run-sql.sh --env dev --script examples/verify-connection.sql --log-level debugIgnored local/runtime files:
.codex/logs/config/connections.conf.DS_Store
Before publishing, confirm no generated logs, wallets, credentials, or local connection maps are staged.