I'm trying to load massive CSV files, via command line, into a shared hosting MySQL account but they've disabled 'load data local infile'. I get this error:
ERROR 1148 (42000) at line 115: The used command is not allowed with this MySQL version
Here's an excerpt of the script I'm using:
CREATE TABLE bk
(
Borough CHAR(2),
Block DECIMAL(5),
Lot DECIMAL(4),
);
load data local infile 'BK.csv' into table pluto_BK fields terminated by ',' optionally enclosed by '"' escaped by '\\' lines terminated by '\n' starting by '' ignore 1 rows
(@vBorough, @vBlock, @vLot)
SET
Borough = nullif(@vBorough,''),
Block = nullif(@vBlock,''),
Lot = nullif(@vLot,'');
Any way around this? Or how can I declare the rules in the last part starting from SET while using phpMyAdmin import?
One workaround would be to just import your data any way possible and then do the following update:
UPDATE bk
SET
Borough = COALESCE(Borough, ''),
Block = COALESCE(Block, 0.0),
Lot = COALESCE(Lot, 0.0);
Note that in this particular case, since you want to replace NULL
(i.e. unassigned) values you could have also specified default values in your table definition:
CREATE TABLE bk (
Borough CHAR(2) DEFAULT '',
Block DECIMAL(5) DEFAULT 0.0,
Lot DECIMAL(4) DEFAULT 0.0
);