All posts

How to Turn a Lead List Into SQL INSERT Statements

··3 min read

To load a lead list into a database, create the table, generate INSERT statements with the CSV to SQL INSERT generator, and run the file on a test table before the real one. The statements are plain text that you run yourself.

What you need

  • A CSV or .xlsx lead list with a header row.
  • A database you can run SQL against: PostgreSQL, MySQL, MariaDB or similar.
  • A test table or test database.

Step 1: load the list

Upload the file or paste the cells with the header row first. The column names are turned into safe names: lower case, with letters, digits and underscores only. Email Address becomes email_address. The names are listed above the SQL.

Step 2: create the table

The tool does not guess column types, so you write the table yourself. A simple version for a lead list:

CREATE TABLE leads (
  email text,
  name text,
  company text
);

Use the column names the tool shows. Add a type or a key if you need one, but keep every column as text if you leave the numbers option off.

Step 3: choose the options

  • Table name. Letters, digits and underscores only.
  • Quoting. Double quotes for standard SQL and PostgreSQL. Backticks for MySQL and MariaDB.
  • Rows per INSERT. A few hundred is usual. One row per statement is slow, and one statement for a very large list can go over a server limit.
  • Blank cells. NULL or an empty string. Pick what your queries expect.
  • Numbers. Off writes every value as text. On writes plain numbers bare. A value with a leading zero stays quoted either way.

Step 4: read the first statement

Look at the first rows in the preview. A name such as O'Hart should be written 'O''Hart'. If something looks wrong, change the options before you download.

Step 5: test, then load

Run the file against a test table. Count the rows with SELECT COUNT(*) and compare with the row count shown in the tool. Only then run it on the real table.

Check the addresses before they go in

A database full of dead addresses stays full of dead addresses. Upload the list to check it first, so the table only holds addresses that exist. The pricing page lists the plans for larger lists. A routine for the whole job is in how to clean an email list, and the list quality check covers what to look at.

If you need a file for an API instead, see how to convert a CSV lead list to JSON.

Common problems

  • A statement fails on a quote. Check the quoting option matches your database.
  • A column is missing. Two headers reduced to the same name, so the second ends in _2. Create the table with that name.
  • The server rejects a large statement. Lower the rows per INSERT.
  • Numbers sorted as text. Create the column as a number type and tick the numbers option.

Frequently asked questions

Is it safe to run? Read it first and run it on a test table. It is plain text, and nothing is run from the browser.

Can I use it for other data? Yes. It works on any CSV, not only lead lists.

Common questions

How do I turn a CSV into SQL INSERT statements?

Upload the CSV to the CSV to SQL INSERT generator or paste the cells with the header row first. Name the table, choose double quotes or backticks, set the rows per INSERT and download the .sql file.

How are quotes in names handled?

A single quote is doubled, so O'Hart is written 'O''Hart'. For MySQL a backslash is doubled too.

Does the tool create the table?

No. It writes INSERT statements only. The column names are shown above the SQL so you can create the table to match.

Is my list uploaded?

No. The SQL is built in your browser.

Check your list before you send

Real mailbox checks over SMTP, and nothing is sent to the address. Sign in with Google and your first 100 email checks are free, no card. Plans for bigger lists are on the pricing page.