db

db remembers one installed database driver and forwards a common compact surface to it without translating the engine’s native language.

DatabaseVersion 1.3.3Stable
lil-terminal

Overview

Use db as a short, session-scoped mirror over an installed database driver: choose MySQL/MariaDB, PostgreSQL, Redis, SQLite or MongoDB once, then reuse the same compact prefix for inspection, export, backups and native engine commands.

One prefix, different engines

db is a common entry point for installed database drivers, not a database engine of its own. It remembers the selected driver and exposes its shared operations, while text after : stays in the database’s native language. This keeps routine work short without pretending that SQL, Redis data structures and MongoDB documents are the same model.

Syntax

lil-terminal
db [driver] [options]

Reference

db

show the selected database driver and installed drivers

db <driver>

select a driver: mysql|postgresql|redis|sqlite|mongodb

-c ...

connect through the selected driver

-use ...

select a database through the selected driver

-l

list databases or namespaces through the selected driver

-t

list tables, collections or keys through the selected driver

-s <name>

show structure through the selected driver

-n <name> [rows]

preview records through the selected driver

-f <name> <text>

search through the selected driver

-o <name> ...

export through the selected driver

-a ...

add data through the selected driver

-w ...

update data through the selected driver

-d ...

delete data through the selected driver

-m [name]

save the current connection through the selected driver

-M <name>

remove a saved connection through the selected driver

-k [name]

list saved connections or inspect one through the selected driver

-K <name>

connect using a saved connection through the selected driver

-e

disconnect the selected driver

db : <native>

run the selected driver's native query or command

db dump ...

create a dump through the selected driver

db load <file>

load a dump or script through the selected driver

Driver selection

The selected driver is stored only in the current PHP session. db mariadb selects mysql because the MySQL driver intentionally covers both MySQL and MariaDB. Selecting a driver never installs it silently; use @mysql or install mysql when the driver is missing.

Common surface

All database drivers use the same core ideas where the engines allow them: -c connects, -use selects a database or file, -l lists databases or namespaces, -t lists tables/collections/keys, -s inspects structure, -n previews data, -f searches, -o exports, dump/load move backups, -e disconnects, and : passes native database syntax.

Native syntax

The text after : belongs to the selected database engine: SQL for MySQL/PostgreSQL/SQLite, a Redis command for Redis, and a JSON command document for MongoDB. db does not translate one database language into another.

Safety

Credentials live only in the active PHP session and passwords are entered through the hidden secret prompt. Driver write operations use the privileges of the connected database account; restricted accounts are recommended.

The common mirror also forwards -a, -w and -d for focused add, update and delete operations; their exact arguments remain driver-specific.

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.

Choose SQLite and inspect a 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 db
Minimum package

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

install db -m
Exact public version

Install exactly this published version.

install db -v 1.3.3
Check or update

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

upgrade db
Remove module

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

install db -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.

Choose SQLite and inspect a table
db sqlite | db -c \sandbox\db\shop.sqlite | db -t | db -n products 5
Driver      sqlite
Status      selected

Status      connected
File        sandbox/db/shop.sqlite

products
orders

id	sku	name	category	price	active
1	SHOE-1	City shoe	shoes	79.9	1
2	SHOE-2	Trail shoe	shoes	109	1
3	BAG-1	Canvas bag	bags	44.5	1
Db · 02
db
Driver      sqlite
SQLite      installed · selected
MySQL       installed
PostgreSQL  not installed
Redis       not installed
MongoDB     not installed
Db · mysql
db mysql
Driver  mysql
Status  selected
Engine  MySQL / MariaDB
Db · mariadb
db mariadb
Driver  mysql
Status  selected
Engine  MySQL / MariaDB
Db · products
db -s products
Field     Type       Null  Key
id        INTEGER    no    PRIMARY
sku       TEXT       no    UNIQUE
name      TEXT       no
category  TEXT       no
price     REAL       no
active    INTEGER    no
Db · products
db -f products "shoe"
id	sku	name	category	price
1	SHOE-1	City shoe	shoes	79.9
2	SHOE-2	Trail shoe	shoes	109
Db · products
db -o products -j products.json
Saved  products.json
Db · products
db -a products : {"sku":"TMP-1","name":"Temporary","price":1}
Inserted  1
ID        5
Db · products
db -w products sku TMP-1 : {"price":2}
Updated  1
Db · products
db -d products sku TMP-1
Deleted  1
Db · select
db : SELECT COUNT(*) AS products FROM products
products
4
Db · dump
db dump backup.sql
Saved  backup.sql
Db · -e
db -e
+
Reject an unsupported driver
db oracle
Unknown database driver: oracle

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

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

CREATE TABLE products (
  id INTEGER PRIMARY KEY,
  sku TEXT UNIQUE NOT NULL,
  name TEXT NOT NULL,
  category TEXT NOT NULL,
  price REAL NOT NULL,
  active INTEGER NOT NULL DEFAULT 1
);
INSERT INTO products (sku,name,category,price,active) VALUES
('SHOE-1','City shoe','shoes',79.90,1),
('SHOE-2','Trail shoe','shoes',109.00,1),
('BAG-1','Canvas bag','bags',44.50,1);

Related documentation

Current public release

v1.3.32026-08-08

Compact database facade

Groups shared flags, forwards connection memory and keeps driver status in compact columns.