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.

  1. -i Parameter has to be specified as jdbc

  2. -s <settings> The JDBC importer requires a settings parameter number of entries.

    • namespace ALFA namespace used for the generated model
    • catalog JDBC catalog used for the import
    • schema JDBC schema used for the import
    • url JDBC url used for the import
    • user JDBC user used for the import
    • password JDBC password used for the import

    All entries should be specified separated by semi-colon.

  3. 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