How sql loader scrip is working?

235 Views Asked by At

Currently I'm working with Exasol database first time and came across one script which is responsible to run sql script written in .sql file.

Here is the script

C:\Program Files\EXASOL\EXASolution\EXAplus\exaplusx64.exe -configDir EXASolutionConfig -profile profile_PROD_talend -q -f D:/Data/Customer/PROD/EXASolution_SQL/EXASOL_data_script.sql -- databaseName tableName /exasolution/StageArea/fileName.csv

I want to know, how this script is working and what its doing actually ? What I understood so far is below

First "C:\Program Files\EXASOL\EXASolution\EXAplus\exaplusx64.exe " is starting a Exasol on command line and then its pointing to the script where .sql file is located.

Not getting:

1) What this part is doing "-configDir EXASolutionConfig -profile profile_PROD_talend -q -f "?


2) What are these identifiers doing "-q -f "?

3)After launching exaplusx64.exe, Is exasol going to connect with database and table name mentioned in script ? If then How cav file is paying its role in this script ? I mean in .sql there is just an sql statement, If its taking data from file then how ? I'm not getting this ..!!

Please share your comments

1

There are 1 best solutions below

0
On

1) This where you say to Exasol to read the profile profile_PROD_talend in the folder EXASolutionConfig and execute the file D:/Data/Customer/PROD/EXASolution_SQL/EXASOL_data_script.sql in quiet mode (-q).

From the manual:

-configDir *This is not actually in the EXASOL manual, I assume it's the folder with the profiles, or maybe it does nothing*
-profile Name of connection profile defined in <configDir>/profiles.xml (profiles can be edited in the GUI version). You can use a profile instead of specifying all connection parameters. 
-q Quiet mode which suppresses additional output from EXAplus.
-f Name of a text file containing a set of instructions that run and then stop EXAplus.

2) Quiet mode and flag for the name of the file.

3) When you run this command EXAPlus connects to the db using the information provided in the profile and it will execute the .sql file passed.

Now things become interesting, the -- allows you to pass some arguments to the .sql file. So you are passing three parameters (databaseName, tableName, and /exasolution/StageArea/fileName.csv). If you open the sql script you will find &1, &2, and &3, these are the placeholders for the parameters passed by your command.

From the manual again:

-- <args> SQL files can use arguments given over via the parameter “-- ” by evaluating the variables &1, &2 etc. .

For example, the file test.sql including the content
--test.sql
SELECT * FROM &1;

can be called in the following way:
exaplus -f test.sql -- dual