I try hard to get my batch to pass parameter to mysql file
my batch :
SET MYSQL_EXE="C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld.exe"
SET DB_USER=root
SET DB_PWD=viper007
SET DB=db01
FOR %%c in (D:\Dev_Algo\Grt_pce\datas\*.*) do (
set "str=%%c"
SETLOCAL ENABLEDELAYEDEXPANSION
call set "str=%%str:\=/%%"
echo SET @fpath ='!str!' > params.sql
ENDLOCAL
type params.sql D:\Dev_Algo\Grt_pce\query0.sql | mysql --user=%DB_USER% --password=%DB_PWD% --database=%DB%
)
my params.sql file
SET @fpath ='D:/Dev_Algo/Grt_pce/datas/LBFLO007.csv'
My sql file (extract)
SET @file=@fpath;
LOAD DATA INFILE @file IGNORE INTO TABLE db01.tblpce
fields terminated by ';'
ignore 1 lines
Result - I can connect to mysql NO PROBLEM - I can load my file with SQL command from MYSQL Workbench - Params file is OK withe single quotes needed for LOAD DATA INFILE - I can't set variable @fpath. I got the error message from batch
ERROR 1064(4200) at line 1 : You have an error in your SQL synthax; check the manual......'SET @file=@fpath' at line 2
I read this http://bugs.mysql.com/bug.php?id=39115 , apparently this functionaly is not implemented. Is this limitation is linked with my error message.
How can I bypass this error, in order to import bulks csv into mysql.
params.sqldoesn't have a newline at the end,typecommand won't add it, so mysql will seeSET @fpath ='.......'SET @file=@fpath;