Csv2Sql image

CSV2SQL - Blazing fast csv to database loader!

Table of Contents

  1. What is Csv2sql ?
  2. Why Csv2sql ?
  3. Using the browser based interface
    1. Installation and usage
  4. Running from source
  5. Supported data types
  6. Handling custom date/datetime formats
  7. Known issues, caveats and troubleshooting
  8. Future plans

Please have a quick look over the Known issues, caveats and troubleshooting section before using the app.

What is Csv2sql?

Csv2Sql is a blazing fast fully automated tool to load huge CSV files into a RDBMS.

Csv2Sql can automatically...

Why Csv2sql ?

Use csv2sql from your browser

For ease of use csv2sql has browser interface which can be used to easily configure the tool and also provides an interface that shows what is the progress of the various running tasks, which files are currently being processed, the current cpu and memory usage, etc.

browser interface demo

Installation and usage: <a name="dashboardinstall"></a>

There are no dependencies needed to use the app via your browser, however you must have mysql or postgres installed.

Download the latest release of the app from the releases section in this repository.

You can now easily run the executable on your linux system, by:

This will run a local server which your access at localhost:4000 in your browser.

Thats all!

Please create an issue with details of your OS distribution, architecture(for example, x86_64 or ARM) and ABI (for example, musl or gnu) if the app does not run on your system

Using the app via the browser is super easy, once the app is running, go to localhost:4000 in your browser.

Now go to the Change configuration tab, and enter the relevant configuration details, hover over any configuration option to see what it does.

Whenever your are done, click on the Start tab and click on Start button below to start the import process.

Running the app from source code

You must have elixir and mysql/postgresql installed in your system to run Csv2Sql.

To use the app just clone this repository and then install dependencies by mix deps.get

Finally, start the application by mix phx.server

This runs the phoenix server at localhost:4000 which provides a browser based interface to use the app.

Thats all !

Supported data types

Csv2sql currently supports MySql and PostgreSQL database.

Csv2Sql will map data in CSVs into one of the following data types:

Type mysql postgres
date For values matching pattern like YYYY-MM-DD or custom patterns NOT SUPPORTED, will map to VARCHAR
datetime For values matching pattern like YYYY-MM-DD hh:mm:ss or custom patterns , (WARNING: fractional seconds or timezone information will be lost if present) NOT SUPPORTED, will map to VARCHAR
boolean Maps values 0/1 or true/false to BIT type Maps values 0/1 or true/false to BOOLEAN type
integer INTINT
float DOUBLENUMERIC(1000, 100)
varchar VARCHAR VARCHAR
text TEXT TEXT

All other types of data, will map to either VARCHAR or TEXT.

Handling custom date/datetime formats

By default csv2sql will identify date or datetime of the following patterns YYYY-MM-DD and YYYY-MM-DD hh:mm:ss respectively. If a csv file contains date or datetime in some other format then they will be imported as varchar by default however by specifying custom patterns we can import such data of arbitrary formats as date or datetime.

csv2sql uses the Timex library to parse date/datetime. You can specify multiple custom patterns for date or datetime as a string having one or more patterns separated by ;

When using the Web UI for csv2sql enter these pattern strings in the config page under "Custom date patterns" or "Custom datetime patterns".

The patterns should be compatible with Timex directives specified here.

(Custom patterns are only supported when using the web ui and are not available in the cli version of the application)

Good to know/Caveats

Examples

To parse datetime like 11/14/2021 3:43:28 PM a pattern like {0M}/{0D}/{YYYY} {h12}:{m}:{s} {AM} can be specified

The custom pattern needed is like...

{0M}/{0D}/{YYYY} {h12}:{m}:{s} {AM}

Consider a CSV with date or datetime having multiple formats like...

Example Date Date Pattern Example Datetime Datetime Pattern
2021-11-14 {YYYY}-{0M}-{0D} 2021-11-14T15:43:28 {YYYY}-{0M}-{0D}T{0h24}:{m}:{s}
11-14-2021 {0M}-{0D}-{YYYY} 11-14-2021 15:43:28 {0M}-{0D}-{YYYY} {0h24}:{m}:{s}
11/14/2021 {0M}/{0D}/{YYYY} 11/14/2021 3:43:28 PM {0M}/{0D}/{YYYY} {h12}:{m}:{s} {AM}

The pattern strings to parse the above csv would look like...

For date {YYYY}-{0M}-{0D};{0M}-{0D}-{YYYY}

For datetime {YYYY}-{0M}-{0D}T{0h24}:{m}:{s};{0M}-{0D}-{YYYY} {0h24}:{m}:{s};{0M}/{0D}/{YYYY} {h12}:{m}:{s} {AM}

Known issues, caveats and troubleshooting:

Future