How to Convert CSV to SQL: Complete Guide
Last updated: 2026-04-14
You have a CSV export from a spreadsheet, a CRM, or an analytics dashboard, and you need to get that data into a relational database. Manually writing INSERT statements is tedious and error-prone. Convertee generates well-formatted SQL from your CSV in one click — with dialect-specific syntax for MySQL, PostgreSQL, SQLite, and SQL Server.
Step-by-Step: Convert CSV to SQL with Convertee
- Open Convertee, choose CSV as source and SQL as target.
- Paste your CSV data or drag a
.csvfile onto the input panel. - Set the SQL options: table name, database dialect, whether to include a CREATE TABLE statement, and INSERT batch size.
- Click Convert (Cmd+Enter).
- Copy the SQL output and run it in your database client.
No data leaves your browser. Convertee parses the CSV and generates SQL entirely in JavaScript.
Understanding the Formats
CSV
CSV is a ubiquitous flat-file format (RFC 4180) used by virtually every database, spreadsheet, and analytics tool for data export. The first row typically names columns, and subsequent rows contain records.
SQL
SQL (Structured Query Language) is the standard language for managing relational databases, defined by ISO/IEC 9075. The INSERT statement adds rows to a table. Syntax details vary between dialects: MySQL uses backtick-quoted identifiers, PostgreSQL uses double-quoted identifiers, and SQLite is generally permissive.
Before / After Example
Input CSV:
name,email,role
Alice,alice@example.com,admin
Bob,bob@example.com,editorOutput SQL (PostgreSQL dialect):
CREATE TABLE IF NOT EXISTS "import_data" (
"name" TEXT,
"email" TEXT,
"role" TEXT
);
INSERT INTO "import_data" ("name", "email", "role")
VALUES
('Alice', 'alice@example.com', 'admin'),
('Bob', 'bob@example.com', 'editor');Common Use Cases
- Database seeding. Populate a development or staging database with test data exported from production as CSV.
- One-time data migrations. Moving data from a legacy system that only exports CSV into a modern PostgreSQL or MySQL database.
- Quick prototyping. You need a working database schema and sample data for a demo. Paste a CSV, get a CREATE TABLE plus INSERTs.
- Classroom exercises. Instructors generate SQL from sample datasets so students can practice queries immediately.
Options and Configuration
| Option | Default | What It Does |
|---|---|---|
| Table name | import_data | Name of the SQL table used in CREATE TABLE and INSERT statements. |
| Dialect | PostgreSQL | Adjusts quoting style, type names, and syntax. Options: MySQL, PostgreSQL, SQLite, SQL Server. |
| CREATE TABLE | On | Prepends a CREATE TABLE statement with column types inferred from the data (TEXT, INTEGER, REAL, BOOLEAN). |
| DROP TABLE | Off | Adds a DROP TABLE IF EXISTS before CREATE TABLE. Useful for repeatable migration scripts. |
| Batch size | 100 | Number of rows per INSERT statement. Large datasets benefit from batching for performance. |
Frequently Asked Questions
- Which SQL dialects does Convertee support?
- MySQL, PostgreSQL, SQLite, and SQL Server. Each dialect uses the correct identifier quoting and type mapping.
- Does Convertee infer column types automatically?
- Yes. It samples the data and assigns types like TEXT, INTEGER, REAL (or DOUBLE), and BOOLEAN. You can always edit the generated CREATE TABLE to refine types.
- Is there a row limit for CSV to SQL conversion?
- The free tier supports CSV files up to 1 MB. For larger datasets, the batch size option splits INSERTs into manageable chunks to avoid query-length limits.
- Can I skip the CREATE TABLE and just get INSERTs?
- Yes. Turn off the 'CREATE TABLE' toggle in the options panel and Convertee will output only INSERT statements.