Skip to main content

Shell Commands

The onql-shell is an interactive Python client for talking to an ONQL server. Everything below is a command you can type at the onql> prompt.

Session basics

CommandPurpose
use <keyword>Set an active verb so you can omit it on every line (e.g. after use onql, you type queries directly)
outClear the active keyword
clearClear the console
exitQuit the shell

Data — read

CommandPurpose
onql <query>Run an ONQL read query (see Language)
onql passwordPrompt for the protocol password for this session
onql contextPrompt for the context key + values for this session

Example:

onql> onql password
enter protocol password :- ********
onql> onql shop.orders[status = "paid"]{id, total}

Data — mutations

CommandPurposeReference
insert <json>Insert a single recordInsert
insert file <path> <db> <table>Bulk-insert every object in a JSON array fileInsert
update <db>.<table> <records-json> on <filter>Update matching rows (shorthand)Update
update <json>Update via raw JSON payloadUpdate
delete <json>Delete rows matching a filterDelete

Examples:

onql> insert {"db":"mydb","table":"users","records":{"name":"Ada","age":36}}
onql> insert file data/users.json mydb users
onql> update mydb.users {"status":"active"} on id = 42
onql> delete {"db":"mydb","table":"users","query":"id = 42"}

Schema

CommandPurpose
schema databasesList all databases
schema tables <db>List tables in a database
schema desc <db> <table>Describe a table's columns
schema create db <db>Create a database
schema create table <db> <table> (col,type,storage,blank,default)...Create a table
schema rename db <old> <new>Rename a database
schema rename table <db> <old> <new>Rename a table
schema alter <db> <table> <op-json>Alter a table (add/drop/rename columns)
schema drop db <db>Drop a database
schema drop table <db> <table>Drop a table
schema set <json_file>Apply a full schema file (declarative migration)
schema refresh-indexesRebuild reverse indexes

Column tuple layout for create table:

(name,string,disk,no,"")
│ │ │ │ └── default value (empty string = none)
│ │ │ └───── blank allowed: yes | no
│ │ └────────── storage: disk | ram
│ └──────────────── type: string | number | bool | date | ...
└───────────────────── column name

Example:

onql> schema create table shop orders (id,number,disk,no,"") (total,number,disk,no,0) (status,string,disk,no,"pending")

Protocol

CommandPurpose
protocol descDescribe the active protocol
protocol set <json_file>Replace the protocol from a JSON file
protocol drop <db> <table>Remove a table's protocol entry

See Concepts → Protocol for what the protocol file controls (auth, context rules, relation wiring).

Stats

CommandPurpose
statsCurrent system stats (connections, memory, active queries, goroutines)
stats queries [limit]Recent query history (default 100)
stats summaryAggregated stats — total, errors, slowest, heaviest, by target
stats clearClear query history

Use stats summary to quickly find slow queries; use stats queries to see the raw last-N log.

Import / Export

CommandPurpose
export all [filename]Export every database
export db <db> [filename]Export one database
export table <db> <table> [filename]Export one table
import <filename> [table <table>]Import from an export file

Export files are plain JSON and round-trip through import. For seeding from scratch (no matching schema yet), prefer insert file ... — it doesn't assume column layout.

Tip — session shortcut

use <verb> is the single biggest ergonomic win. After:

onql> use onql
onql> shop.orders[status = "paid"]{id, total}
onql> shop.customers._count()
onql> out
onql> insert {"db":"shop","table":"...","records":{...}}

...you don't retype onql on every read. Run out to drop the prefix when you switch verbs.