CSV to SQL converter
Turn a CSV or Excel file into CREATE TABLE and INSERT statements for PostgreSQL, MySQL, SQL Server or SQLite. Your file never leaves your browser.
Drop a CSV or Excel file here
CSV, TSV or .xlsx, up to 100 MB. It stays on your computer.
- No sign-up
- Nothing uploaded
- Column types picked for you
A script you can run as it is.
Your file stays on your computer
The SQL is written in your browser. Nothing is sent to Mammoth or anyone else.
Written for your database
PostgreSQL, MySQL, SQL Server and SQLite each quote names, type columns and write true/false their own way. Pick yours.
Column types from your data
Totals become DECIMAL, IDs become INTEGER, dates become DATE, and a code column like 02134 stays text.
How to convert CSV to SQL
The header row names the columns, every value decides its column's type, and the rows go in as INSERT statements of 500.
- 1
Add your file
Drop a CSV or Excel file on the box, choose one, or paste CSV in.
- 2
Pick the database
Choose PostgreSQL, MySQL, SQL Server or SQLite and name the table.
- 3
Download or copy
Save the .sql file, or copy it into your SQL editor and run it.
Other ways to do it
Every database has its own loader. They are fast, but each needs the table made first, by hand.
Your database's bulk loader
Big files, a table that exists
- Writes CREATE TABLE for youNo
- Picks column typesNo
- No code or installNo
- Runs on a scheduleYes
Python with pandas
A job you script once
- Writes CREATE TABLE for youYes
- Picks column typesYes
- No code or installNo
- Runs on a scheduleYes
- This page
This converter
A file you need in a database now
- Writes CREATE TABLE for youYes
- Picks column typesYes
- No code or installYes
- Runs on a scheduleNo
How to import a CSV into a database
Each database has a bulk loader: COPY or \copy in PostgreSQL, LOAD DATA INFILE in MySQL, BULK INSERT in SQL Server. They need the table to exist first. For SQLite, or with Python, these two lines do the whole job.
Need the data as JSON for an API instead? Use the CSV to JSON converter.
sqlite3 shop.db ".import --csv orders.csv orders"
Creates the table from the header row, but every column is TEXT, so totals sort as text.
import sqlite3
import pandas as pd
pd.read_csv("orders.csv").to_sql("orders", sqlite3.connect("shop.db"), index=False)pandas picks the column types. For PostgreSQL or MySQL, pass a SQLAlchemy engine instead of the sqlite3 connection.
Your file stays private
The converter runs inside this page. Your file is read and written out as SQL on your computer, and nothing is sent to Mammoth. That makes it safe for customer and payment records.
Once the page has loaded, it works with your internet switched off.
Loading CSV files into a database every week?
Mammoth can do it for you. Put the files in a folder, and the combined table is appended or upserted into PostgreSQL, MySQL or SQL Server on a schedule.
Partner files
| Acme | Nov 02 | Order 1041 | 129.50 | |
| Borel | Nov 02 | Order 5512 | 64.00 | |
| Cato | Nov 03 | Order 9020 | 1,480.00 | |
| Acme | Nov 09 | Order 1077 | 310.25 | |
| Borel | Nov 09 | Order 5530 | 92.10 |
Illustration. Every new file in the folder is added to the same table.