Skip to main content
CSV to SQL Converter

MySQL & MariaDB SQL

CSV to MySQL Converter

Convert CSV and TSV datasets into backtick-quoted MySQL INSERT batches, ON DUPLICATE KEY UPDATE statements, and CREATE TABLE DDL locally.

100% Client-Side — Your CSV never leaves your browser.
Mode

Input Data

0 rows · 0 cols

Tip: Drag & drop a .csv or .tsv file anywhere in this panel.

SQL Output

0 statements
-- Generated SQL will appear here.
-- Paste CSV/TSV data, drop a file, or click "Load Sample CSV".
Shortcut: Cmd/Ctrl+Shift+C to copy SQL0 data rows processed

Convert CSV to MySQL Queries Without LOAD DATA INFILE Restrictions

Managed MySQL and MariaDB deployments frequently disable LOAD DATA LOCAL INFILE by default for security reasons, leaving developers hunting for a clean way to turn spreadsheet exports into portable SQL scripts. This csv to mysql converter lets you convert csv to mysql locally in your browser without sending sensitive customer, order, or analytics tables across the internet.

Whether you are seeding a local Docker instance, updating a staging database via phpMyAdmin or MySQL Workbench, or committing a migration script, generating a batched csv to mysql insert script gives you full visibility and transaction control over every row before it executes.

Backtick Identifier Escaping & Safe String Literals

In standard MySQL configurations (without ANSI_QUOTES enabled), double quotes denote string literals rather than column names. Using unquoted headers like group, order, or status causes immediate query failures. This csv to mysql generator automatically wraps every table and column name in backticks—such as `users` and `full_name`—and doubles any embedded backtick character (``) to prevent broken DDL or DML statements.

For cell values, single quotes are escaped as doubled apostrophes ('O''Connor'), which works identically across standard MySQL modes including NO_BACKSLASH_ESCAPES. Blank cells convert to unquoted NULL unless you disable the empty-as-NULL toggle.

Multi-Row Batching & ON DUPLICATE KEY UPDATE Upserts

Inserting rows one query at a time incurs heavy round-trip latency and disk-sync overhead in InnoDB. By setting Batch Size to 50, 100, or 500 rows, the converter packs tuples into fast multi-row INSERT INTO `table` (...) VALUES (...), (...); statements while avoiding oversized packets that could exceed max_allowed_packet.

When re-importing updated exports where primary or unique keys already exist in your table, switch Query Mode to UPSERT. The engine emits an idiomatic ON DUPLICATE KEY UPDATE clause updating every non-key column cleanly. Combine it with CREATE TABLE IF NOT EXISTS to infer INT, BIGINT, DECIMAL(18, 4), BOOLEAN, DATETIME, and TEXT columns in one click.

Frequently Asked Questions

Common Questions & Dialect Details

Why does the MySQL converter use backticks around table and column names?

MySQL uses backticks (`table`, `column`) to delimit identifiers so column names containing spaces or reserved keywords like `order` or `key` never trigger syntax errors. Literal backticks inside names are escaped as doubled backticks.

How does MySQL UPSERT work with ON DUPLICATE KEY UPDATE?

When UPSERT mode is active, the generator appends an ON DUPLICATE KEY UPDATE clause after the multi-row INSERT VALUES block, updating every non-key column using VALUES(`column`) whenever a PRIMARY KEY or UNIQUE index collides.

What batch size should I choose for large MySQL INSERT scripts?

Batches of 100 or 500 rows significantly accelerate MySQL imports by reducing network round-trips and index flushes, while staying safely below default max_allowed_packet limits on most MySQL and MariaDB servers.

How are CSV values like booleans, numbers, and timestamps formatted for MySQL?

Booleans emit unquoted TRUE or FALSE, numeric integers and decimals emit unquoted with full precision, ISO timestamps map to DATETIME in CREATE TABLE DDL, and strings escape apostrophes as doubled single quotes ('').

Does this MySQL converter work with MariaDB and PlanetScale?

Yes. Backtick identifier quoting, multi-row INSERT batching, CREATE TABLE IF NOT EXISTS, and ON DUPLICATE KEY UPDATE syntax are fully compatible with MySQL 5.7/8.x, MariaDB, and Vitess-based hosts.