Database Schema Importer¶
It is possible to extract ALFA definitions from a Database allowing to quickly get started with a ALFA data model.
Most if not all maintream databases have a JDBC driver that allows connecting using Java JDBC. Using this driver, ALFA is able to extract ALFA types from table definitions. The ALFA model importer is run from the command line using the ALFA command-line tool, or from the ALFA Maven Plugin as an importer.
If using theCLI, the JDBC jar file path needs to be set as an environment variable.
export ALFA_OPT_JARS=<path to your database JDBC driver>
Arguments to the CLI.
-iParameter has to be specified asjdbc-s <settings>The JDBC importer requires a settings parameter number of entries.namespaceALFA namespace used for the generated modelcatalogJDBC catalog used for the importschemaJDBC schema used for the importurlJDBC url used for the importuserJDBC user used for the importpasswordJDBC password used for the import
All entries should be specified separated by semi-colon.
Last parameter is the directory path where the generated ALFA file is written to
alfa -i jdbc -s namespace=model;catalog=schema=accounts;url=jdbc:oracle:thin:@//dbserver:1521/xe;user=jbloggs;password=changeme ./generated/schema