postgresql

postgresql connects to PostgreSQL, inspects tables and rows, makes focused changes, exports data, runs native SQL and creates logical backups.

DatabaseVersion 1.1.3Stable
lil-terminal

Overview

Use postgresql for a consistent PostgreSQL workflow: hidden-password connections, schema and row inspection, focused changes, exports, native SQL and logical backups without shell tools.

PostgreSQL without flattening its model

PostgreSQL is a client-server relational database with strong typing, transactions and a rich native SQL language. A database can contain schemas, and schemas contain tables and other objects, so “schema” here is also a database namespace—not only a description of columns. Use the short surface for inspection and routine changes, then native SQL after : when PostgreSQL-specific features matter.

Syntax

lil-terminal
postgresql [options] · postgresql : <sql>

Reference

postgresql

show the current PostgreSQL connection

postgresql -c <host> <user> [database] [-p <port>] [-n] [-m [name]]

connect; password is requested separately unless -n is used

-use <database>

select another database by reconnecting

-l

list databases

-t

list public tables and views

-s <table>

show columns and data types

-n <table> [rows]

preview table rows

-f <table> <text> [rows]

find text across table columns

-o <table> [-j|-csv] [file] [-f]

export table rows

-a <table> : <json>

insert one row from a JSON object

-w <table> <field> <value> : <json>

update matching rows from a JSON object

-d <table> <field> <value>

delete matching rows

-m [name]

save the current connection in .lil.key; default name is the database

-M <name>

remove a saved connection

-k [name]

list saved connections or inspect one without showing its password

-K <name>

connect using a saved connection

-e

disconnect and clear connection data

postgresql : <sql>

execute native SQL

postgresql load <file.sql|file.json>

execute SQL or restore a lil logical JSON dump

postgresql dump [file.json] [-f]

create a logical JSON dump of public tables

Inspection

-l lists databases, -t lists public tables/views, -s shows column definitions, -n previews rows and -f searches text across one table. -o exports table rows as JSON or CSV.

Editing

-a inserts one JSON object, -w updates rows selected by one field/value pair and -d deletes matching rows. Use native SQL for joins, transactions and advanced PostgreSQL features.

Dump and restore

Because lil does not invoke system pg_dump, dump creates a logical JSON snapshot of public table rows. load restores that lil JSON format or executes a supplied SQL file. Use the server's native backup tooling when a complete PostgreSQL cluster/schema backup is required.

Connection

-c requests the password outside command history. -use reconnects to another database with the same session credentials.

Safety

Commands run with the privileges of the connected PostgreSQL user.

The lil JSON dump is data-only: schema objects and indexes are not recreated. JSON restore is transactional, and export or dump refuses a table above 100000 rows instead of writing partial data.

Saved connections

Without -m, connection data remains scoped to the current PHP session. -m [name] explicitly stores the current profile in the protected .lil.key file (0600), -K <name> reconnects from it, -k lists or inspects profiles without exposing a stored password, and -M <name> removes one. kill removes .lil.key together with the other core state. Treat the file as sensitive because an opted-in profile can contain database credentials.

Interactive sandbox preview

Run the prepared examples directly on the page. Their results are prebuilt and shown in the browser; no terminal command is executed on the server.

Inspect a PostgreSQL table

Install and manage

Install the current compatible version. Choose Base for the complete feature set or Minimum for the reduced package; use upgrade to update a module that is already installed.

Base and Minimum are two packages of the same current module release, not separate command versions.

Base package

Install the complete package with local command reference and every published mode.

install postgresql
Minimum package

Install the reduced package. Local reference is omitted; help <cmd> -i opens the current server reference.

install postgresql -m
Exact public version

Install exactly this published version.

install postgresql -v 1.1.3
Check or update

Ask upgrade to check compatibility and replace the installed block only when needed.

upgrade postgresql
Remove module

Remove the extension block while leaving the core and unrelated modules intact.

install postgresql -u

Examples

Examples are copyable command lines, not actions executed by this website. Review paths, permissions and destructive flags before running them on a real project.

Inspect a PostgreSQL table
postgresql -use shop | postgresql -t | postgresql -n products 5
Database  shop

products
orders

id	sku	name	category	price	active
1	SHOE-1	City shoe	shoes	79.90	t
2	SHOE-2	Trail shoe	shoes	109.00	t
Postgresql · localhost
postgresql -c localhost app shop
Status    connected
Server    PostgreSQL 17
Host      localhost:5432
User      app
Database  shop
Postgresql · -l
postgresql -l
postgres
shop
template1
Postgresql · products
postgresql -s products
Column    Type           Nullable
id        bigint         no
sku       text           no
name      text           no
category  text           no
price     numeric(10,2)  no
active    boolean        no
Postgresql · products
postgresql -f products "shoe" 20
id	sku	name	category	price
1	SHOE-1	City shoe	shoes	79.90
2	SHOE-2	Trail shoe	shoes	109.00
Postgresql · products
postgresql -o products -j products.json
Saved  products.json
Postgresql · products
postgresql -a products : {"sku":"BAG-1","name":"Travel bag","price":49.90}
Inserted  1
Postgresql · products
postgresql -w products sku BAG-1 : {"price":44.90}
Updated  1
Postgresql · products
postgresql -d products sku BAG-1
Deleted  1
Postgresql · select
postgresql : SELECT COUNT(*) AS products FROM products
products
4
Postgresql · dump
postgresql dump shop.json
Saved  shop.json
Postgresql · load
postgresql load \sandbox\db\postgresql.sql
Affected  2
Time      2 ms
Postgresql · -e
postgresql -e
+
Handle a missing table
postgresql -s missing_table
Table not found: missing_table

File used in this example: sandbox/db/postgresql.sql

The example uses a file or directory from the protected /sandbox/ documentation workspace.

CREATE TABLE products (id BIGSERIAL PRIMARY KEY, sku text UNIQUE NOT NULL, name text NOT NULL, category text NOT NULL, price numeric(10,2) NOT NULL, active boolean NOT NULL DEFAULT true);
INSERT INTO products(sku,name,category,price,active) VALUES ('SHOE-1','City shoe','shoes',79.90,true),('BAG-1','Canvas bag','bags',44.50,true);

Related documentation

Current public release

v1.1.32026-08-14

Saved connections

Adds explicit -m/-M/-k/-K profiles in .lil.key; listings never reveal a stored password.