Import CSV into SQLite on Mac and verify the result

15 minutes · Editing license required for creation and import

Move a small contact list into SQLite, then verify what was actually stored. The important step is checking the result, not just seeing “import complete.”

1. Start with a new database

Choose File → New Database…, select the blank SQLite option and save it under a new name such as contacts-practice.sqlite. Unlock the database for writing. A CSV is a text file; choosing Open Database on the CSV is not an import.

2. Review and import the CSV

Choose File → Import CSV… and select contacts.csv. Review the delimiter, header and preview. Enable Create new table, name it contacts, and keep Header row enabled, using the header names name, email and postal_code. Confirm only after the preview has three columns and the names line up with their values.

Petti’s new-table inference preserves leading-zero identifiers as text. Postal codes are identifiers here, not quantities. Importing into a pre-existing numeric column can apply different SQLite affinity rules, so use a new table for this exercise.

3. Check values and types

Choose contacts in the sidebar, then run this query in Query:

SELECT name, postal_code, typeof(postal_code) AS stored_as
FROM contacts
ORDER BY name;

Expect Alex Chen → 04567, Maya Rao → 00123, and Sam Rivera → 01001, with text in stored_as for all three. If zeros disappeared earlier in a spreadsheet, importing cannot reconstruct them. Compare with the original CSV.

4. Verify the count and export

Confirm there are three records. Use SELECT count(*) FROM contacts; when you need an exact count. Return to Data, choose File → Export → CSV, and select Entire Table. Save under a new filename and inspect it in a text editor. A spreadsheet may reinterpret codes when reopening even a correct export.

Apply this to a larger import

Check a small representative file first, including blanks, embedded commas, quotes and non-ASCII names. Before adding rows to an important existing database, create a snapshot and check constraints and duplicate rules. Import adds data; it is not a general merge or automatic deduplication tool. Relock the database when finished.

Updated