Upgrade various dependencies and some code cleanup
Remove timestamp and add datetime column type support
MySQL attempts to convert timezone to UTC when using timestamp columns. In order to avoid this we are now using datetime to store date time data instead of timestamp.
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.
In this PR we add support for specifying custom patterns to import date or datetime data of arbitrary formats.
In order to specify custom patterns for date or datetime use the --custom-date-patterns or --custom-datetime-patterns arguments followed by 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.
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
Description
This PR contains the following changes
Code improvements
Upgrade various dependencies and some code cleanup
Remove
timestamp
and adddatetime
column type supportMySQL attempts to convert timezone to UTC when using
timestamp
columns. In order to avoid this we are now usingdatetime
to store date time data instead oftimestamp
.Add support for a custom date or DateTime formats
Fixes https://github.com/Arp-G/csv2sql/issues/11
By default csv2sql will identify date or datetime of the following patterns
YYYY-MM-DD
andYYYY-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.
In this PR we add support for specifying custom patterns to import date or datetime data of arbitrary formats.
In order to specify custom patterns for date or datetime use the
--custom-date-patterns
or--custom-datetime-patterns
arguments followed by 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.
Examples
To parse datetime like
11/14/2021 3:43:28 PM
a pattern like{0M}/{0D}/{YYYY} {h12}:{m}:{s} {AM}
can be specifiedThe complete command might look like...
./csv2sql --source-csv-directory "/home/user/Desktop/csvs" --db-connection-string "mysql:root:pass@localhost/test_csv" --custom-datetime-patterns "{0M}/{0D}/{YYYY} {h12}:{m}:{s} {AM}"
From Web UI