In mySQL workbench database, one of the tables has latitude, longitude and district attributes
lat: decimal (10,8)
lng: decimal (11,8)
district: int(4)
I'm trying to import data from .csv file to this table
ERROR 1366: 1366: Incorrect decimal value: '' for column 'lat' at row 1
SQL Statement:
ERROR 1366: 1366: Incorrect integer value: '' for column 'district' at row 1
SQL Statement:
INSERT INTO `db`.`myTable` (`id`, `name_en`, `icon`, `lat`, `lng`, `district`, `city`, `postal_code`)
VALUES ('686', 'Name',?, '', '', '','1', 'P.O. Box 1111')
You have strict sql mode enabled, and you try to pass an empty string ('') as value for decimal fields in the insert. Empty string is an invalid value for a numeric field and in strict sql mode mysql generates an error if you try to insert an invalid data into a column, rather than providing a warning and use the default value (0 for numeric columns) of the particular column's data type:
Remove the strict sql mode for the session before starting the import:
Remove STRICT_TRANS_TABLE from
global sql_mode
. You might required other attributes such as NO_ZERO_DATE in global sql_mode if already set.Set this under [mysqld] in my.cnf (or /etc/mysql/mysql.conf.d/mysqld.cnf) depending on your server version.