Schema Importer is a CLI tool for automatically configuring PostgreSQL. By using this tool, your PostgreSQL database can have identical database objects, such as namespaces and tables, as your ScalarDB instance.

Schema Importer reads the ScalarDB configuration file, retrieves the schemas of the tables defined in ScalarDB, and creates the corresponding foreign data wrapper external tables and views in that order. For more information, refer to Getting Started with ScalarDB Analytics with PostgreSQL.

Build Schema Importer

You can build Schema Importer by using Gradle. To build Schema Importer, run the following command:

./gradlew build

You may want to build a fat JAR file so that you can launch Schema Importer by using java -jar. To build the fat JAR, run the following command:

   ./gradlew shadowJar

After you build the fat JAR, you can find the fat JAR file in the app/build/libs/ directory.

Run Schema Importer

To run Schema Importer by using the fat JAR file, run the following command:

java -jar <PATH_TO_FAT_JAR_FILE>

Available options are as follows:

Name Required Description Default
--config Yes Path to the ScalarDB configuration file  
--config-on-postgres-host No Path to the ScalarDB configuration file on the PostgreSQL-running host The same value as --config will be used.
--namespace, -n Yes Namespaces to import into the analytics instance. You can specify the --namespace option multiple times if you have two or more namespaces.  
--host No PostgreSQL host localhost
--port No PostgreSQL port 5432
--database No PostgreSQL port postgres
--user No PostgreSQL user postgres
--password No PostgreSQL password  
--debug No Enable debug mode  

Test Schema Importer

To test Schema Importer, run the following command:

./gradlew test

Build a Docker image of Schema Importer

To build a Docker image of Schema Importer, run the following command, replacing <TAG> with the tag version of Schema Importer that you want to use:

docker build -t<TAG> -f ./app/Dockerfile .