Skip to content

SQLite CLI API

sqlite3 command-line shell dot-commands for opening databases, dumping data and inspecting schemas.

1 class · 5 methods

Dot Commands

5 methods

sqlite3 shell commands prefixed with a dot.

.open [file]

Closes the current database and opens the given file; ':memory:' for an in-memory database.

Parameters

NameTypeDescription
filestringDatabase file path or ':memory:'.

Returns

void

Example

sqlite
.open ./app.db
.dump [tbl]

Renders the entire database (or a single table) as SQL text suitable for backup or migration.

Parameters

NameTypeDescription
tblstringOptional table name to dump.

Returns

void

Example

sqlite
.dump users > users.sql
.import file table

Imports CSV or text data from file into the named table.

Parameters

NameTypeDescription
filestringInput file path.
tablestringTarget table name.

Returns

void

Example

sqlite
.mode csv
.import users.csv users
.schema [tbl]

Shows the CREATE statements for the database or for the named table.

Parameters

NameTypeDescription
tblstringOptional table name.

Returns

void

Example

sqlite
.schema users
.tables [pattern]

Lists table names in the database, optionally filtered by a LIKE pattern.

Parameters

NameTypeDescription
patternstringOptional LIKE pattern.

Returns

void

Example

sqlite
.tables user%