Skip to content

Convert CSV to SQLite

Drop your CSV file to get a SQLite script with CREATE TABLE and INSERT statements. Each column gets a type, and every fix is listed with its row and column.

Your file
csvventas_2024.csvSample file, 357 B
Your database

5 rows converted, 8 fixes, none rejected

Show
The first rows of ventas_2024.csv, with each fix marked
Row
500412Peña MuñozMérida15/02/20241.234,50sí
600413José Ángel RuizLeón03/02/202499,90no
700414Zoë OrtízQuerétaro29/02/2024N/Así
800415Ñuño CastañedaOaxaca28/02/20247,25no
900416Iñaki OlaizolaMazatlán11/03/2024980,75sí
-- Written by IntoSQL for SQLite.

BEGIN;

CREATE TABLE ventas_2024 (
    folio TEXT NOT NULL,
    cliente TEXT NOT NULL,
    ciudad TEXT NOT NULL,
    fecha DATE NOT NULL,
    importe NUMERIC(6,2),
    pagado BOOLEAN NOT NULL
);

INSERT INTO ventas_2024 (folio, cliente, ciudad, fecha, importe, pagado) VALUES
('00412', 'Peña Muñoz', 'Mérida', '2024-02-15', 1234.50, 1),
('00413', 'José Ángel Ruiz', 'León', '2024-02-03', 99.90, 0),
('00414', 'Zoë Ortíz', 'Querétaro', '2024-02-29', NULL, 1),
('00415', 'Ñuño Castañeda', 'Oaxaca', '2024-02-28', 7.25, 0),
('00416', 'Iñaki Olaizola', 'Mazatlán', '2024-03-11', 980.75, 1);

COMMIT;

Fixes

  1. The file was written in windows‑1252; it was converted to UTF-8.
  2. The header is on row 4; the rows above it were left out.
  3. Row 10 ("TOTAL") is a total, so it was left out.
  4. Leading zeros kept in "Folio": 00412 stays 00412, stored as text.
  5. 15/02/2024 proves the dates in "Fecha" are day-first, so 03/02/2024 is read as 2024‑02‑03.
  6. Numbers in "Importe" use a decimal comma: 1.234,50 is read as 1234.50.
  7. N/A in "Importe" read as empty (1 of 5 values).
  8. "Pagado" holds yes and no words (sí, no), stored as boolean.

Your file is converted on this computer and never uploaded.

Other samples:

From CSV to SQLite, column by column

The sample above, ventas_2024.csv, as IntoSQL writes it for SQLite: what each column holds in the file, the type it gets and how its first value lands in the script.

In the fileFirst valueColumnSQLite typeIn the script
Folio00412folioTEXT'00412'
ClientePeña MuñozclienteTEXT'Peña Muñoz'
CiudadMéridaciudadTEXT'Mérida'
Fecha15/02/2024fechaDATE'2024-02-15'
Importe1.234,50importeNUMERIC(6,2)1234.50
PagadosípagadoBOOLEAN1

Load the script into SQLite

The download is a plain .sql file. Run it with SQLite's own tools.

From a terminal

sqlite3 ventas_2024.db < ventas_2024.sqlite.sql

The database file is created if it doesn't exist. The converter also downloads a ready .sqlite database, with no command at all.

From a database tool

In DB Browser for SQLite, choose Execute SQL, open the script and run it.

Without a script

The command line loads the file straight into a SQLite database, without writing a script. It's free.

intosql load ventas_2024.csv --into ventas_2024.db

What to know about CSV files and SQLite

What IntoSQL reads in CSV files

  • The encoding is detected, Windows-1252 and UTF-16 included, so accents and ñ arrive intact.
  • The separator is detected: comma, semicolon, tab or vertical bar. With a semicolon, decimal commas like 1.234,50 are read as numbers.
  • Quoted values can hold separators and line breaks.

What to know about SQLite

  • Each column gets the type its values need, like INTEGER, NUMERIC, TEXT, DATE or BOOLEAN; yes and no are stored as 1 and 0.
  • Decimals with more than 15 digits stay TEXT, so no digit is rounded away.
  • Download the SQLite script, or a ready .sqlite database built in your browser.

How each kind of value is stored in SQLite

ValueSQLite
Yes and noBOOLEAN
Whole numbersINTEGER
Large whole numbersINTEGER
DecimalsNUMERIC(p,s)TEXT
Floating-point numbersREAL
DatesDATE
Times of dayTIME
Dates with a timeDATETIME
Dates with a time and offsetDATETIME
TextTEXT

Questions about CSV to SQLite

Not answered here? Write to us from the contact page and a person replies. Contact page

How do I convert CSV to SQLite?

Drop your file on the converter at the top of this page. It finds the header, reads every value and writes the SQLite script, listing each fix it made. Download the script and run it with sqlite3.

What if my CSV uses semicolons or tabs?

The separator is detected: comma, semicolon, tab or vertical bar. You can also set it under More options. With a semicolon, decimal commas such as 1.234,50 are read as numbers.

Which SQLite types does it use?

Yes and no values become BOOLEAN, whole numbers INTEGER, decimals NUMERIC(p,s), dates DATE, dates with a time DATETIME and text TEXT. Sizes come from the longest value in each column.

Does it keep leading zeros in SQLite?

Yes. A code such as 00412 stays text, so SQLite stores it as TEXT and the script writes it as '00412'.

Can it load the data into SQLite without a script?

Yes, for free: intosql load creates the SQLite database file and loads the rows in. The converter on this page also downloads a ready .sqlite database.

How big can the CSV file be?

The browser reads a CSV as it streams in, so files of several gigabytes work. On an Apple M4 laptop the command line converts a 174 MB CSV of a million rows in under a second.