sqlite3 Command Reference: Flags, Dot-Commands & CI Examples
sqlite3 is the command-line shell for SQLite database files.
sqlite3 opens a SQLite file (or an in-memory database) and runs SQL plus dot-commands. With no server to wait on, it is a lightweight fixture and report engine in CI.
Common flags and usage
- sqlite3 db.sqlite "SQL": run a statement and exit
- .read <file>: execute SQL from a file
- .dump: emit SQL that recreates the database
- .mode csv / -csv: CSV input and output
- .import <file> <table>: bulk-load a file into a table
- -batch / -bail: non-interactive; stop on first error
Example
shell
sqlite3 -bail app.db < schema.sql
sqlite3 -csv app.db 'SELECT id,email FROM users' > users.csvIn CI
Use -bail so a failing statement stops the script and fails the step. sqlite3 .dump produces a portable SQL backup; redirect it to a file to snapshot a fixture database between jobs.
Key takeaways
- sqlite3 runs SQL and dot-commands against a file or :memory: db.
- -bail makes a failing statement fail the CI step.
- .dump exports a portable SQL snapshot of the database.
Related guides
psql Command Reference: Flags, Usage & CI ExamplesReference for the psql PostgreSQL client: connection flags, -c and -f, PGPASSWORD, ON_ERROR_STOP, and a CI ex…
mongodump Command Reference: Flags, Usage & CI ExamplesReference for mongodump: --uri, --db, --collection, --gzip, --archive, and a CI example that exports a MongoD…
yq Command Reference: Flags, Expressions & CI ExamplesReference for yq: reading and editing YAML/JSON, -i in-place edits, -o output format, env() interpolation, an…