I am trying to load a bunch of images as seed data into MySQL as part of the build process. Currently, I have an image.sql file that contains binary data, which the mysql client tools will happily import into MySQL:
Unfortunately, the ant sql task fails to parse this file correctly because of the binary data and fails. I've tried combinations of keepformat, encoding, and escapeprocessing, but I still can't execute that sql file via ant.
I have a shell script that loads the data, but I'd really like to be able to use ant and not require mysql client tools or cygwin/unix to be able to load data into the database.
Here are my options: a) Find out a way to make the ant sql task work with binary data b) Find out a way to load binary data using mysql's load_file with ant. The load_file function requires an absolute path, so I would need some way to only specify relative paths in the sql file and have ant do the rest. I dont think this is even possible. c) The least attractive option is to have a <exec> task execute the mysql binary with the correct args. But I dont think there's a way to do unix file redirection; it wouldn't work on Windows.
Min, I don't think it is possible to do this with the sql task. Another alternative is to write a Java program that does the load through JDBC. You would be dependent on a mysql driver, but you wouldn't need the mysql client or exec.