DevForge

Markdown table to SQL

Seed data usually starts life in a document. This turns a Markdown table into the statements needed to put it in a database: a CREATE TABLE with types inferred from the column contents, and batched INSERTs with identifiers and string literals quoted the way your dialect expects.

markdown
sql
options
format
grid

how to use it

  1. 01Paste Markdown containing a table.
  2. 02Pick your SQL dialect and name the table.
  3. 03Copy the statements into a migration or a psql session.

questions

How are column types chosen?
From the values: all whole numbers give INTEGER, decimals give NUMERIC, true and false give BOOLEAN, ISO dates give DATE, and anything else stays TEXT.
Is my data escaped safely?
Single quotes are doubled, and for MySQL backslashes are escaped too, since MySQL treats them as escape characters inside string literals where the others do not.
Why is SQL Server output split into batches?
A multi-row VALUES clause in SQL Server is capped at 1000 rows, so longer tables are emitted as several INSERT statements.

related