'How to get a Mariadb prepared statement using LOAD DATA LOCAL INFILE working

I am not able to get LOAD DATA LOCAL INFILE working as a prepared statement. Error 1064 is thrown, but the syntax displays correctly as a select statement (as text). Local infile is enabled "local_infile=true" in cnf file, and I am able to import files using the same statement shown below replacing variables with actual values. Any help in pointing me in the right direction is gratefully appreciated. Of note, mariadb knowledgebase mentions "LOAD DATA INFILE is unsafe for statement-based replication." Is this the reason the prepared statement and subsequently a stored procedure won't work?
Thanks again.

SET @sql := 'LOAD DATA LOCAL INFILE ? INTO TABLE ? 
FIELDS OPTIONALLY ENCLOSED BY \'\"\' TERMINATED BY \'\,\' 
LINES TERMINATED BY \'\\n\' 
(item, price, pdetail, @store, @purchased)
SET store = ?';
PREPARE stmt_loadmeup FROM @sql;
EXECUTE stmt_loadmeup USING 'full path to file.csv','TEST','TH';



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source