pq.q

The session itself: version, open connections, terminal size and colour support, and the standard-library load sequence. Nothing here is loaded at start-up: the first reference to any .pq name loads this file, whose first line - .pq.load_natives`pq, the one .pq member that exists before it runs - binds the C functions it calls. The console's syntax colours are .pq.hl.

Examples

.pq.version
select handle, alias from .pq.conns[]

Entity Summary

EntitiesShort Description
.pq.cancolor[]Whether stdout should carry ANSI colour: PEACHQ_COLORS=0/1 overrides everything, then NO_COLOR (off), FORCE_COLOR (on), else a tty whose TERM is not dumb.
.pq.conns[]Every open connection, one row each; -38! keeps kdb's letters, these are the same facts in words.
.pq.dr[verb]Print a verb's domain and range grid in the layout the KX reference pages use, probed with a sample of every type (an atom each side of a dyad, a three-item vector for a monad): a lower-case letter is an atom result, upper-case a list, "." an error.
.pq.hlThe console's syntax colours, role to colour, read by the highlighter at each redraw.
.pq.hopen_duckdb[alias;arg]Attach a DuckDB database as `:pq:duckdb:alias, the same call as hopen (`:pq:duckdb:alias;arg).
.pq.hopen_kafka[alias;arg]Open a Kafka client as the alias `:pq:kafka:alias; arg is librdkafka's config as a dict of its keys, metadata.broker.list at least and group.id to subscribe.
.pq.hopen_q[alias;arg]Open (or re-point) `:pq:q:alias on another q process, the same call as hopen (`:pq:q:alias;arg); answers that symbol.
.pq.hopen_qfork[alias;arg]Fork this process as the worker `:pq:qfork:alias, the same call as hopen (`:pq:qfork:alias;arg).
.pq.hopen_qspawn[alias;arg]Launch a fresh peachq as the worker `:pq:qspawn:alias, the same call as hopen (`:pq:qspawn:alias;arg).
.pq.info[x]What peachq itself holds behind a `:pq: handle, a dict of tables: a table coordinate answers `schema (col dtype logical iskey t, as bound on first touch); an alias answers `tables (table origin bound: what is bound, `q or `duckdb by the sidecar, when) and `stats (binds hits rebinds dropped).
.pq.load[files]Load standard-library files not already loaded; \l pq/.q always reloads.
.pq.render_modern[x]The modern display of x as a string: exactly what the console prints when it is not in \classic mode, whatever the session's mode, clipped by \c like .Q.s.
.pq.summary[t]One line of facts about a table, one per column in column order: numeric columns as min-max, booleans as the share true, everything else as a distinct count (`all distinct` when every row differs; a temporal column that repeats shows its range), with a null count where there are nulls.
.pq.termsize[]The live terminal size, with the 25/80 fallback and [10,2000] clamp that \c 0N uses.
.pq.tlsinfo[]How each HTTPS client in this process checks a server's certificate, one row per transport: `peachq for .Q.hg, read0, select from an https URL and hopen of tcps:// or wss://, and `duckdb once DuckDB's httpfs extension is loaded.
.pq.versionThe peachq version string.

Entity Details

.pq.cancolor[]

Whether stdout should carry ANSI colour: PEACHQ_COLORS=0/1 overrides everything, then NO_COLOR (off), FORCE_COLOR (on), else a tty whose TERM is not dumb.

Return: boolean

Examples

.pq.cancolor[]

.pq.conns[]

Every open connection, one row each; -38! keeps kdb's letters, these are the same facts in words.

Columns:
  • protocol - `q or `ws on a socket; family `tcp or `unix
  • handle - the int: what .z.pc gets and neg works on, for an alias too
  • pid - the worker an owned alias kills on hclose; owned says it has one
  • spec - the alias symbol (`:pq:qfork:w1) hopen answered, null for a plain handle

Examples

.pq.conns[]
exec handle from .pq.conns[] where spec=`:pq:qfork:w1

.pq.dr[verb]

Print a verb's domain and range grid in the layout the KX reference pages use, probed with a sample of every type (an atom each side of a dyad, a three-item vector for a monad): a lower-case letter is an atom result, upper-case a list, "." an error. After KX's tools.q (qdocs/docs/docs/tools.q, CC BY 4.0).

Parameters:
  • verb - a symbol or char naming a verb in .Q.ops[], or a function

Examples

.pq.dr `neg
.pq.dr "+"

.pq.hl

The console's syntax colours, role to colour, read by the highlighter at each redraw. Roles: kw keywords, str strings, esc string escapes, cmt comments, sym symbols, num numbers, tmp temporals and typed nulls, op verbs and adverbs, sys system names, cmd \ commands, match the bracket or quote pair at the cursor. A colour is an int 0-255 (a 256-colour foreground) or a string of digits and ; used as the SGR parameters. A role left out, or given anything else, keeps its default; with colour off (.pq.cancolor) nothing is coloured. Amend in place (.pq.hl[`kw]:141) or set it in QINIT; loading this file again resets it. The defaults mirror the C table in src/qlang/repl/q_highlight.c - change both together.

.pq.hopen_duckdb[alias;arg]

Attach a DuckDB database as `:pq:duckdb:alias, the same call as hopen (`:pq:duckdb:alias;arg).

Parameters:
  • arg - (any) the path or ":memory:", or a dict of `path beside DuckDB's own ATTACH and SET options

.pq.hopen_kafka[alias;arg]

Open a Kafka client as the alias `:pq:kafka:alias; arg is librdkafka's config as a dict of its keys, metadata.broker.list at least and group.id to subscribe. The alias consumes and publishes.

Examples

.pq.hopen_kafka[`c1;`metadata.broker.list`group.id!`localhost:9092`myapp]

.pq.hopen_q[alias;arg]

Open (or re-point) `:pq:q:alias on another q process, the same call as hopen (`:pq:q:alias;arg); answers that symbol.

Parameters:
  • arg - (any) what hopen takes (port, `::5000, `:host:port:user:pass, (conn;timeout) ...), or a `conn`timeout dict

.pq.hopen_qfork[alias;arg]

Fork this process as the worker `:pq:qfork:alias, the same call as hopen (`:pq:qfork:alias;arg).

Parameters:
  • arg - (any) :: for the defaults, a timeout in ms, or a dict of `timeout`stdout`stderr: `stdout`stderr!(`:w1.out;`:w1.err) sends the worker's output to those files, as \1/\2 run by the worker before anything else

.pq.hopen_qspawn[alias;arg]

Launch a fresh peachq as the worker `:pq:qspawn:alias, the same call as hopen (`:pq:qspawn:alias;arg).

Parameters:
  • arg - (any) its argv, one string per argument ("" or :: for none), or a dict of `argv`timeout`stdout`stderr: `argv`stdout`stderr!(("init.q";"-s";"2");`:logs/w2.log;`:logs/w2.log) logs its startup script's output too

.pq.info[x]

What peachq itself holds behind a `:pq: handle, a dict of tables: a table coordinate answers `schema (col dtype logical iskey t, as bound on first touch); an alias answers `tables (table origin bound: what is bound, `q or `duckdb by the sidecar, when) and `stats (binds hits rebinds dropped). Connection facts are .pq.conns[]; the catalog is SQL.

Parameters:
  • x - the `:pq: symbol; anything else is 'type, an alias that is not open 'conn

Examples

.pq.info hopen (`:pq:duckdb:demo;":memory:")

.pq.load[files]

Load standard-library files not already loaded; \l pq/.q always reloads.

Return: (symbol list) the files this call loaded
Parameters:
  • files - (symbol|symbol list) the files to load; [] for every library file

Examples

.pq.load`regexp

.pq.render_modern[x]

The modern display of x as a string: exactly what the console prints when it is not in \classic mode, whatever the session's mode, clipped by \c like .Q.s. A table or keyed table is the pipe table; anything else is the text .Q.s returns, which is always the classic display.

Return: (string) the display, ending in a newline
Parameters:
  • x - (any) the value to render

Examples

.pq.render_modern ([]a:1 2;b:`x`y)

.pq.summary[t]

One line of facts about a table, one per column in column order: numeric columns as min-max, booleans as the share true, everything else as a distinct count (`all distinct` when every row differs; a temporal column that repeats shows its range), with a null count where there are nulls. The same facts the console digest prints under a clipped table, so the two never disagree.

Return: string, `-1`-ready
Parameters:
  • t - (table) a table or keyed table

Examples

.pq.summary ([]a:1 2 3;b:`x`y`x)

.pq.termsize[]

The live terminal size, with the 25/80 fallback and [10,2000] clamp that \c 0N uses.

Return: (rows;cols)

Examples

.pq.termsize[]

.pq.tlsinfo[]

How each HTTPS client in this process checks a server's certificate, one row per transport: `peachq for .Q.hg, read0, select from an https URL and hopen of tcps:// or wss://, and `duckdb once DuckDB's httpfs extension is loaded. With no SSL_CA_CERT_FILE or SSL_CA_CERT_PATH set, peachq trusts the operating system's roots: Windows' root store, or OpenSSL's default bundle elsewhere. SSL_VERIFY_SERVER=NO turns checking off.

Columns:
  • ca_file - the trusted roots' bundle file, "" where none applies; ca_path the same for a directory of roots
  • openssl_version - the OpenSSL peachq loaded, "" when there is none
  • ca_source - `env when SSL_CA_CERT_FILE or SSL_CA_CERT_PATH names the roots, `os for Windows' root store, `default for the library's own default locations, `setting for DuckDB's ca_cert_file
  • verify - whether the server's certificate is checked
  • last_error - why peachq's last TLS connection failed, "" after one that worked; the error it signalled is 'conn
  • overridden_by - the environment variables (or DuckDB settings) that move this row off its default

Examples

.pq.tlsinfo[]
first exec last_error from .pq.tlsinfo[] where transport=`peachq