Export SQLite to CSV on Mac

Use the sqlite3 shell for a repeatable query export, or Petti’s export action for a graphical workflow. Both can read the database without enabling edits.

Export with the SQLite command-line shell

Choose a new output path so you do not overwrite a file you need. This example assumes an events table with the named columns; adapt the query to your schema.

sqlite3 -readonly "/path/to/database.sqlite"
.headers on
.mode csv
.once /path/to/events.csv
SELECT id, event_type, created_at
FROM events
ORDER BY id;
.quit

.once sends the next statement’s output to the file. Put quotes around a path that contains spaces. CSV mode handles delimiters, embedded quotes and line breaks; hand-joining values with commas does not. See the SQLite shell’s CSV export documentation.

Export fewer rows or columns

List the columns you need instead of using SELECT *. Add a WHERE clause to narrow the result, or LIMIT 1000 for a sample. Large output still takes time and disk space even though the rows can be streamed.

Export from Petti

  1. Open the database and select a table.
  2. Apply search and filters if you want to narrow the data.
  3. Choose File → Export → CSV → Filtered Result and a destination file. Use Entire Table instead if you want to ignore browse conditions.

Filtered Result exports the matching table data, rather than just the pages already loaded in the grid. Export runs as a streaming operation. The free read-only mode includes export; importing CSV or changing database data requires a license and writable access.

CSV is data interchange, not a database backup

CSV does not preserve indexes, constraints, relationships or SQLite types. Decide how you want to represent NULL: the shell’s default empty representation can be ambiguous with empty strings. You can set a marker with .nullvalue NULL, but a literal text value of “NULL” then needs its own convention.

Spreadsheet apps may reinterpret dates, long identifiers or leading zeros. Values beginning with formula characters can also be treated as formulas; inspect untrusted exports before opening them in a spreadsheet. Keep a proper SQLite backup if you need to restore the database.