When writing scripts for running MySQL in batch mode, it is often desired to be able to change the SQL queries on-the-fly so that we can use the script to solve more generic problems.
For example, I need to use my script for different storage engines and table names and I want to be able to do it at runtime instead of manually changing my script every time.
Here is how I do it:
I have a template file which is my script but with the
variables having generic names. In this case, I have
considered plugin_name as the storage engine name , and
table_name as the table name.
Consider the following script:
# automation-script-template # Mixing shell commands and SQL queries in batch mode- demo script # Replace variables: plugin_name, table_name with appropriate names- done automatically by …[Read more]