-
Open the database in read-only mode:
sqlite3 -readonly api/app.db
-
List tables (inside the sqlite3 prompt):
.tables
-
Inspect a table schema (inside the sqlite3 prompt):
.schema users
-
Count rows (inside the sqlite3 prompt):
SELECT COUNT(*) FROM users;
-
Read a small sample (inside the sqlite3 prompt):
SELECT user_id, email, first_name, last_name FROM users LIMIT 5;
-
Filter with a condition (inside the sqlite3 prompt):
SELECT user_id, email, active FROM users WHERE active = 1 LIMIT 5;
-
Join organizations and roles (inside the sqlite3 prompt):
SELECT
o.organization_id,
o.name,
r.user_id,
r.permission_level
FROM organizations o
JOIN roles r ON r.organization_id = o.organization_id
LIMIT 5;
-
One-off read without entering the prompt:
sqlite3 -readonly api/app.db "SELECT COUNT(*) FROM organizations;"