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.
Before running the CLI, 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.
-i
Parameter has to be specified asjdbc
-s <settings>
The JDBC importer requires a settings parameter number of entries.namespace
ALFA namespace used for the generated modelcatalog
JDBC catalog used for the importschema
JDBC schema used for the importurl
JDBC url used for the importuser
JDBC user used for the importpassword
JDBC 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 will be written to
alfa -i jdbc -s namespace=model;catalog=schema=accounts;url=jdbc:oracle:thin:@//dbserver:1521/xe;user=jbloggs;password=changeme ./generated/schema