DbSchema can automate different processes using Java Groovy scripts with direct access to the DbSchema API.
DbSchema APIGroovy is a pure Java language with closures, known for being used by Gradle. The variables in ${...} are evaluated. The scripts can be edited and tested in the SQL Editor.
// Copy code in DbSchema SQL Editor and choose Groovy
sql.eachRow("select * from address") { r ->
println "Gromit likes ${r.address_id}"
}
String multiline = """I am a multiline
text"""
The following variables are exposed directly to the Groovy script engine :
sql | The physical connection to the database. |
project | The DbSchema project, with schemes, tables, columns, etc.. |
out | The Result Pane print stream. |
DbSchema can start in headless mode (no interface) and execute Groovy scripts using: Dbschema.exe -x <path-to-script>.
To start DbSchema in headless mode use java -cp "lib/*" com.wisecoders.dbs.DbSchema -x path_to_sample_script.
Adding further parameters to the command will pass this variables as an array under the variable parameters.
In the Tools / Automation Scripts you can find different code samples.
If you wish, our team can help you to write your own script. Please write us using Help / Contact Support.