scriptella / scriptella-etl

Scriptella is an open source ETL (Extract-Transform-Load) and script execution tool written in Java
https://scriptella.org
Apache License 2.0
104 stars 45 forks source link

How to copy files in one of the steps? #14

Closed hansgru closed 9 years ago

hansgru commented 9 years ago

How to copy files in one of the steps while the etl.xml is run?

E.g. after a few steps imported some data in the DB (h2), than the DB file needs to be copied somewhere else, and than other further steps need to be done on the original one, than copied again somewhere, etc.

Thank you.

seansummers commented 9 years ago

I would use the script, jexl or janino drivers to write the logic you need (hammer principle), break your etl process into several scripts that you can run between administrative operations (respect des fonds), or you may just want to re-visit your logic to write to your destinations simultaneously (scriptella doesn't limit you to one target connection at a time).

hansgru commented 9 years ago

@seansummers Thanks for your help.

Unfortunately janio does not seem to work, but using the script driver seems to work. Also there's no need to break the scripts even further (they are already broken in 10+ etl.xml files that group transactions.

I did the following (requires Java 7+), so it might be useful in the FAQ section so that other uses don't need to search:

    <connection id="script" driver="script"/>
    .... tasks before ...
    <script connection-id="script">
        java.lang.System.out.println("Try to copy files with Scriptella ....");
        java.nio.file.Files.copy(
            (new java.io.File("etl/step_3/file_to_copy.db")).toPath(),
            (new java.io.File("etl/out/file_to_copy.db")).toPath()
        );
    </script>
   ...tasks after...
seansummers commented 9 years ago

It is janino not janio BTW.

I'm glad that worked, but still wonder why writing directly to both locations in your script wouldn't.

If it's all good, please close this issue.