Documentation Automation - Non interactive mode

DbSchema Scripts, Schema & Synchronization
Post Reply
nhubert
Posts: 5
Joined: Wed Sep 12, 2018 2:50 pm

Documentation Automation - Non interactive mode

Post by nhubert » Wed Sep 12, 2018 2:57 pm

Automation Scripts
DbSchema can be started in non-interactive mode and automatically execute Groovy scripts. The script have full control over the DbSchema logic, so it can reverse engineer the schema, generate documentation, etc. This way different operations an be automatized.

Hello,

Where can I find documentation on how to execute groovy script in non-interactive mode ? I would like to generate documentation based on this forum thread : https://www.dbschema.com/forum/viewtopic.php?f=22&t=1085

I have read this page : https://www.dbschema.com/documentation/sql.html but nothing about non-interactive mode.

I am on Windows.

Thank you
Last edited by nhubert on Mon Oct 01, 2018 1:30 pm, edited 1 time in total.

support
Posts: 93
Joined: Tue Dec 01, 2015 8:44 am

Re: Automation Documentation - Non interactive mode

Post by support » Wed Sep 19, 2018 10:58 am

Please check DbSchema Help / Automation and SQL Editor / Groovy

nhubert
Posts: 5
Joined: Wed Sep 12, 2018 2:50 pm

Re: Automation Documentation - Non interactive mode

Post by nhubert » Thu Sep 20, 2018 8:53 pm

I am using this documentation https://www.dbschema.com/documentation/ and when doing a ctrl+f looking for "automation" there is 0 resullt. Inside the application it redirects on the same web page with no search capabilities.

I can't even find a link to the documentation starting from your landing page : https://www.dbschema.com/

What documentation are you referring to ? Please be more precise and helpful.

mattmc3
Posts: 5
Joined: Mon Nov 28, 2016 8:35 pm

Re: Automation Documentation - Non interactive mode

Post by mattmc3 » Thu Sep 27, 2018 8:55 pm

@nhubert - it's unclear whether you are using MacOS or Windows or what version of DbSchema you're on, but I see the automation documentation by choosing Help... Help Contents (F1) and scrolling down to "Automation using DbSchema" and clicking the link. I'm on a Mac, DbSchema v8.0.7.

nhubert
Posts: 5
Joined: Wed Sep 12, 2018 2:50 pm

Re: Automation Documentation - Non interactive mode

Post by nhubert » Fri Sep 28, 2018 1:07 pm

Hello Matt,

Support contacted and admitted their mistake, the link was not present and was added on September 24.

If it can help document this issue, here is the reply from support:
Hello Nicolas,
Our mistake, the link was missing, now we fixed it. Look here : http://www.dbschema.com/documentation/automation.html
Also please update to the current version from website ( is still version 8.0.7 but a higher buildnum. New version will come end of this week ).
I have stated on my first post that I am on Windows. You are right, I forgot to mention the version I am using: DbSchema 8.0.7 build 5129.

With the documentation uploaded I was able to execute the script, which works. Unfortunately it opens the DbSchema loading screen and never close after the script has done its job. I have to manually close it. I am waiting for a support answer on this.

Image

On the documentation page, the script is a copy/past from this post : https://www.dbschema.com/forum/viewtopic.php?f=22&t=1085 with the comments removed :

Image

Without knowledge of GitHub Pages or the link to the original post it was taken from, this code is not understandable. It should be removed or explained.

Hope it helps.
Last edited by nhubert on Mon Oct 01, 2018 1:30 pm, edited 1 time in total.

mattmc3
Posts: 5
Joined: Mon Nov 28, 2016 8:35 pm

Re: Automation Documentation - Non interactive mode

Post by mattmc3 » Fri Sep 28, 2018 1:37 pm

Yes, I agree - leaving in the Jekyll frontmatter piece is unnecessarily confusing for getting started with automation. On the other hand, using GitHub Pages to publish DbSchema models is next level awesome, so maybe the thinking was that leaving it in may benefit someone???

One thing that really helped me debug was figuring out how to override the forced log4j output to a file and get back to using stdout. Here's how I finally did it:

Code: Select all

// hello.groovy
// usage:
// MacOS: /Applications/DbSchema.app/Contents/MacOS/JavaApplicationStub -x /full/path/to/file/hello.groovy
// Windows: DbSchema.exe -x C:\full\path\to\hello.groovy
import com.wisecoders.dbs.schema.*;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.PrintStream;

println "Hello from println"  // won't print
System.out.println "hello System.out.println" // nope

// get stdout back
System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)))

println "Hello from println take 2"  // still won't print
System.out.println "hello from System.out.println take 2" // YES!!!

nhubert
Posts: 5
Joined: Wed Sep 12, 2018 2:50 pm

Re: Automation Documentation - Non interactive mode

Post by nhubert » Fri Sep 28, 2018 5:40 pm

Thank you very much Mattmc3 for your input ! I will have a look into it.

My end goal is to have a CI pipeline that generate and publish HTML documentation for each DbSchema change.

nhubert
Posts: 5
Joined: Wed Sep 12, 2018 2:50 pm

Re: Documentation Automation - Non interactive mode

Post by nhubert » Thu Oct 04, 2018 1:12 pm

The loading screen issue has been fixed on DbSchema 8.0.8. Thanks

Do you know if it's possible to generate/export as Image in groovy script ?

I have taken a look at this documentation : https://www.dbschema.com/documentation/javadoc/overview-summary.html

Looked for : export/generate/image/jpg/png keywords not luck so far finding a matching function.

Post Reply