Execute .sql file in talend

Highlighted
Six Stars

Execute .sql file in talend

How to execute .sql file in talend when i run a job?

 

for example:

 

    If i run a job in talend the file(.sql) which i  placed in desktop should be triggered and it should affect in  mysql database  

 

   The .sql file may contain any qurey like create table or update or insert etc........


Accepted Solutions
Community Manager

Re: Execute .sql file in talend

Hi 

Set the Use Home Directory to <Mysql installation directory/bin>, and execute the command like

"cmd /c mysql -uUsername -pPassword -DDatabaseName <D:/files/in.sql"

Snipaste_2019-11-28_09-53-49.png

----------------------------------------------------------
Talend | Data Agility for Modern Business

View solution in original post


All Replies
Community Manager

Re: Execute .sql file in talend

Hi
You can use a tsystem to execute a command to execute the .sql file like you do it from CMD.

Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Six Stars

Re: Execute .sql file in talend

hi,

 

  can you please explain me how we can do it in tsystem component

 

Thanks

Eight Stars

Re: Execute .sql file in talend

You should be able to do it by reading the file into a string with a tFileInputRaw component, write the contents into the globalMap, and use the globalMap entry as the Query in a tMysqlRow component.

Community Manager

Re: Execute .sql file in talend

Hi 

Set the Use Home Directory to <Mysql installation directory/bin>, and execute the command like

"cmd /c mysql -uUsername -pPassword -DDatabaseName <D:/files/in.sql"

Snipaste_2019-11-28_09-53-49.png

----------------------------------------------------------
Talend | Data Agility for Modern Business

View solution in original post

Eight Stars

Re: Execute .sql file in talend

I can just see the expression on our security manager's face. "That's a password... in plain text... in a Talend job... you're fired!"

Six Stars

Re: Execute .sql file in talend

hi shong,

 

 

  Thanks now it is working

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Put Massive Amounts of Data to Work

Learn how to make your data more available, reduce costs and cut your build time

Watch Now

How OTTO Utilizes Big Data to Deliver Personalized Experiences

Read about OTTO's experiences with Big Data and Personalized Experiences

Blog

Talend Integration with Databricks

Take a look at this video about Talend Integration with Databricks

Watch Now