Replacing the content of a SQL File


(Mohan Rao) #1


We have a requirement to create a database in MYSQL server using gradle. We have below two files.

  1. file : From where I will fetch the database name, below is the content of file.

2. dbscript.sql file : Where I have the SQL statements to create database. Below is the content of SQL file.

CREATE SCHEMA IF NOT EXISTS customer_db_name DEFAULT CHARACTER SET utf8 COLLATE ‘utf8_general_ci’;

Requirement : We need replace the customer_db_name in SQL file with CUSTOMERDBNAME variable value and execute that SQL file to create the DB. Please help me in doing this.


(uklance) #2

You could use a Copy task along with filter(…) eg ReplaceTokens