I haven't worked with ERD for quite some time, but back when I did I used
SQL Power Architect:
http://www.bestofbi.com/page/architectIt's a java GUI application, offered via open core model (community version is GPLv3 licenced, and you can buy extensions and support), but the community version should be quite useful.
Wrt scripting, I expect that you can import schema of existing database and if I recall correctly, one could theoretically reuse the xslt transformations (which implements export features) outside of the app to eg. convert xml with the ERD diagram into html or sql script outside of the app (which could be useful for CI/CD).