Back to lessons

Hosting Operations

Show Recent SQLite Events

You need the most recent event rows from a SQLite events table.

Command

sqlite3 app.db "SELECT created_at, event_type FROM events ORDER BY created_at DESC LIMIT 5;"

What changed

Nothing changes. The command reads recent rows from the events table.

Danger

safe

When to use it

Use when reconstructing a simple timeline from local app data.

When not to use it

Do not use it as a replacement for durable logs if the table is sampled or pruned.

Undo or recovery

No undo needed because this command is read-only.

Expected output

Recent timestamps and event types, newest first.

demo script

Disposable terminal steps

  1. sqlite3 app.db ".schema events"
  2. sqlite3 app.db "SELECT created_at, event_type FROM events ORDER BY created_at DESC LIMIT 5;"

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ sqlite3 app.db ".schema events"
CREATE TABLE users (id INTEGER PRIMARY KEY, email TEXT NOT NULL, created_at TEXT NOT NULL);
CREATE UNIQUE INDEX idx_users_email ON users(email);
CREATE TABLE orders (id INTEGER PRIMARY KEY, user_id INTEGER NOT NULL, total_cents INTEGER NOT NULL, created_at TEXT NOT NULL);
CREATE INDEX idx_orders_user_id ON orders(user_id);
CREATE TABLE events (id INTEGER PRIMARY KEY, event_type TEXT NOT NULL, created_at TEXT NOT NULL);
::exit-code::0
$ sqlite3 app.db "SELECT created_at, event_type FROM events ORDER BY created_at DESC LIMIT 5;"
2026-06-25T12:10:00Z|checkout_completed
2026-06-25T12:08:00Z|login
2026-06-25T12:05:00Z|page_view
::exit-code::0

YouTube Short

Read recent SQLite events.

When a tiny app stores events in SQLite, order by timestamp and limit the output for a quick timeline.

LinkedIn hook

For small apps, the quickest timeline may be inside the SQLite file.

Question: Do your small apps keep enough event data for local timeline checks?

experiments

A/B tests to run

Metric: watch_time

A: Local timeline.

B: Recent rows first.