Skip to content

Libraries on the command line

Your saved libraries work in octa --sql exactly as in the app, and four flags manage them without the Settings dialog. Here they always work: the app's Libraries button exists because its queries can also run on a server, and --sql always runs on local DuckDB. They read and write the same settings.toml (OCTA_CONFIG_DIR moves it).

Querying them

octa --sql -q 'SELECT r.*, s.region FROM raw.orders r JOIN sales.customers s USING (customer_id)'
octa --sql data.csv -q 'SELECT * FROM data JOIN sales.customers USING (customer_id)'

A query of libraries alone needs no file. Only the libraries the query names are reached. A library that could not be used is a warning: line on stderr, and the query then fails on the name it could not find; a fetched table the row limit cut is a warning: too (pass --rows all, or set fetch_all=true on the library). A table a SELECT counted and grouped on its own server gets a line on stderr saying so; only that result was fetched (see Counting and grouping run on the server). A --sql-table or --sql-attach name wins over a saved library of the same name for that run.

Managing them

octa --list-libraries
octa --add-library 'name=sales,connection=warehouse,schema=sales'
octa --add-library 'name=shop,connection=shop'                 # a DuckDB file connection
octa --add-library "name=raw,path=$HOME/exports"               # a folder
octa --add-library 'name=lake,connection=prod-s3,key=raw/2026/'
octa --add-library 'name=sales,connection=prod-s3,key=lake/,subfolders=folders'
octa --add-library 'name=orders,connection=prod-s3,key=lake/orders/,subfolders=one_table'  # a Delta table
octa --test-library sales
octa --remove-library raw

--list-libraries prints name, kind, source, write_as (how a query names the tables), fetch_all, subfolders and problem (why a library cannot be used). It connects to nothing.

--add-library takes key=value pairs: name= and either connection= (a saved database or cloud connection, by name or id) or path= (a folder or file). Narrow a database with catalog=, schema= and table=; pick a cloud folder or object with key= (a folder ends in /); pick one table of a multi-table file with table=. fetch_all=true lifts the row limit for tables the library has to copy. subfolders= says how a folder library reads the folders below it, one of off (the default), files, folders, names or one_table; see Subfolders. Only the name is checked (letters, digits and underscores, not starting with a digit, not an SQL word, unique ignoring case); nothing connects. A library with the same name is replaced, keeping its id.

--test-library reaches the source with as little as it can. A database is only logged in to, with one SELECT 1, and a cloud folder is asked for its first object; both print Connection OK. A cloud file is looked up alone, a file or folder on this computer prints how many tables it maps, or that its one table is there. It fetches no rows and exits 1 when the source cannot be reached. A query with --sql on a cloud folder library that reads subfolders stops listing at the Settings limit (library_list_max_objects, 100,000 by default) and says the folder holds more. --remove-library also drops the tables the library fetched.

See also