I have an SQL script, in which some data is being loaded from a file, something like this:

LOAD DATA local INFILE 'test.csv'
  INTO TABLE test ...

Now the path & name of this INFILE is hardcoded for now, but is it possible to provide this INFILE's path as a parameter to this .sql file? if yes, how??

  • Typically, embed the SQL text in a Bash shell, and use a bash substitution to insert an argument to the script, into the SQL command (best to test it exists first, in the script). Alternative: use a fixed name in the SQL, but create a symbolic link to the specific data file before running, and rm the link (not the data itself) after use. – Paul_Pedant Jul 22 at 10:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.