Convert TSV to SQL

Turn TSV files into SQL. SQL in SQLite's dialect that creates one table named data, its columns typed from the values, such as integers, decimals, dates and text, and inserts every row, as SQLite's .dump writes it inside one transaction, so MySQL and PostgreSQL do not run it as it is.

Converted in an isolated sandbox on our serversDeleted after 24 hours

Drop TSV files on the dialor turn it to pick what to do

A SQL script that rebuilds your table.One table named data, with a column type for each column and every row inserted.

  1. What you get

    A SQL script in SQLite's dialect. It creates one table named data and inserts every row, written the way SQLite's .dump writes it, inside one transaction.

    Each column is typed from its values, such as integers, decimals, dates and text. A column that mixes numbers and text further down is kept as text.

  2. Column names

    With Header row on, which is the default, the first row gives the column names. Turn it off when the first row is data. The columns are then named column0, column1 and so on.

  3. Where the script runs

    The script is written for SQLite. MySQL and PostgreSQL do not run it as it is.

    Decimals keep every digit SQLite stores, so 41.7 comes out as 41.700000000000002842. Expect long decimal values in the INSERT statements.

    To go the other way, use SQL to TSV.

TSV and SQL.What each format is, and the options this conversion takes.

  1. 01 · header

    Header row

    Whether the first row holds the column names rather than data.

    default true

The formats

From · TSV

Tab-Separated Values

Tab-separated values.

Extensions
.tsv .tab
MIME type
text/tab-separated-values
Kind
Text and data
To · SQL

SQL Script

SQL statements as text. A database dump that any SQL tool can read or replay.

Extensions
.sql
MIME type
application/sql
Kind
Text and data

In your code.The same TSV to SQL conversion through the API, for your app or your agent.

terminal
$ cv convert sheet.tsv sheet.sql
$ cv convert sheet.tsv sheet.sql

Questions.What people ask about TSV to SQL.

01OF 04

The table is named data. The script creates it and inserts every row into it.

Not as it is. The script is in SQLite's dialect, so MySQL and PostgreSQL do not run it without changes.

Decimals keep every digit SQLite stores. For 41.7, that is 41.700000000000002842.

Turn off Header row. The first row is then treated as data, and the columns are named column0, column1 and so on.

More conversions.Other ways in and out of TSV and SQL.