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.4Stable
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

What it does

db is a shortcut to a database driver, not a database and not a translator between SQL, Redis and MongoDB. Choose db sqlite for a database stored in a file or db mysql for a MySQL/MariaDB server. You can still call sqlite and mysql directly; the same driver performs the operation.

Practical steps

Select the driver first, then connect: db sqlite -c \sandbox\db\shop.sqlite. Inspect tables with db -t, look at a few records with db -n products 2, and search with db -f products "shoe". The native command after db : belongs to the selected engine. db mariadb selects mysql; it does not install a missing driver.

Limits and safety

The chosen driver and an ordinary connection remain in the PHP session. -m [name] explicitly saves a connection profile to the sensitive .lil.key file; -k lists it, -K reconnects and -M removes it. Prefer limited database accounts, back up before -a/-w/-d, load or arbitrary native commands, and check that both the driver and its PHP extension are available. Examples use isolated data, not your live database.

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.4
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
No database driver selected
mysql       MySQL / MariaDB · installed
postgresql  PostgreSQL · installed
redis       Redis · installed
sqlite      SQLite · installed
mongodb     MongoDB · installed
Select a driver: mysql|postgresql|redis|sqlite|mongodb
db sqlite
Database driver selected: sqlite
Select a driver: mysql|postgresql|redis|sqlite|mongodb
db mariadb
Database driver selected: mysql
Select a driver: mysql|postgresql|redis|sqlite|mongodb
db oracle
Unknown database driver: oracle
Connect through the selected driver
db sqlite -c \sandbox\db\shop.sqlite
Status  connected
File    sandbox/db/shop.sqlite
SQLite  (version depends on the host)
Select a database through the selected driver
db sqlite -use \sandbox\db\shop.sqlite
Status  connected
File    sandbox/db/shop.sqlite
SQLite  (version depends on the host)
List tables, collections or keys through the selected driver
db sqlite -c \sandbox\db\shop.sqlite | db -t
name	type
orders	table
products	table
Show structure through the selected driver
db sqlite -c \sandbox\db\shop.sqlite | db -s products
cid	name	type	notnull	dflt_value	pk
0	id	INTEGER	0	NULL	1
1	sku	TEXT	1	NULL	0
2	name	TEXT	1	NULL	0
3	category	TEXT	1	NULL	0
4	price	REAL	1	NULL	0
5	active	INTEGER	1	1	0
Preview records through the selected driver
db sqlite -c \sandbox\db\shop.sqlite | db -n products 2
id	sku	name	category	price	active
1	SHOE-1	City shoe	shoes	79.9	1
2	SHOE-2	Trail shoe	shoes	109.0	1
Search through the selected driver
db sqlite -c \sandbox\db\shop.sqlite | db -f products "shoe"
id	sku	name	category	price	active
1	SHOE-1	City shoe	shoes	79.9	1
2	SHOE-2	Trail shoe	shoes	109.0	1
List databases or namespaces through the selected driver
db sqlite -c \sandbox\db\shop.sqlite | db -l
seq	name	file
0	main	sandbox/db/shop.sqlite
Run the selected driver's native query or command
db sqlite -c \sandbox\db\shop.sqlite | db : SELECT COUNT(*) AS total FROM products
total
4
Time  (varies) ms
Export through the selected driver
db sqlite -c \sandbox\db\shop.sqlite | db -o products -j
[
  {
    "id": 1,
    "sku": "SHOE-1",
    "name": "City shoe",
    "category": "shoes",
    "price": 79.9,
    "active": 1
  },
  {
    "id": 2,
    "sku": "SHOE-2",
    "name": "Trail shoe",
    "category": "shoes",
    "price": 109.0,
    "active": 1
  },
  {
    "id": 3,
    "sku": "BAG-1",
    "name": "Canvas bag",
    "category": "bags",
    "price": 44.5,
    "active": 1
  },
  {
    "id": 4,
    "sku": "HAT-1",
    "name": "Summer hat",
    "category": "accessories",
    "price": 25.0,
    "active": 0
  }
]
Reject an unsupported driver
db sqlite -c \sandbox\db\shop.sqlite | db -a products : {"sku":"NEW-1","name":"Sample","category":"test","price":5,"active":1}
Inserted  1
ID        5
Update data through the selected driver
db sqlite -c \sandbox\db\shop.sqlite | db -w products sku HAT-1 : {"price":24}
Updated  1
Delete data through the selected driver
db sqlite -c \sandbox\db\shop.sqlite | db -d products sku HAT-1
Deleted  1
Save the current connection through the selected driver
db sqlite -c \sandbox\db\shop.sqlite | db -m demo
Saved  demo
List saved connections or inspect one through the selected driver
db sqlite -k
No saved connections
Connect using a saved connection through the selected driver
db sqlite -K absent
Saved connection not found: absent
Remove a saved connection through the selected driver
db sqlite -M absent
Saved connection not found: absent
Disconnect the selected driver
db sqlite -c \sandbox\db\shop.sqlite | db -e
+
Create a dump through the selected driver
db sqlite -c \sandbox\db\shop.sqlite | db dump tmp/sample-db.sql
Saved  sandbox/tmp/sample-db.sql
Load a dump or script through the selected driver
db sqlite -c \sandbox\db\shop.sqlite | db load db/sqlite.sql
SQLite error: table products already exists

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.42026-11-01

Production refinement

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