PGX 20.1.1
Documentation

Loading Graphs from a Database

PGX supports loading graph data from a database in the following formats:

Additionally, PGX supports the database as a data provider for partitioned graph loading by using the rdbms format in a provider configuration.

In order for PGX to be able to read the data in the database, you need to provide suitable credentials with permissions to access the data. Since version 19.3.0, PGX uses a keystore to handle credentials.

Configuring Database Credentials with a Keystore

The first step is saving your database password in a keystore. The following example generates a new keystore using the standard keytool CLI, which is bundled with the JDK.

#!/bin/bash

# Add a password for the 'database1' connection
keytool -importpass -alias database1 -keystore keystore.p12
# 1. Enter the password for the keystore
# 2. Enter the password for the database

# Add another password (for the 'database2' connection)
keytool -importpass -alias database2 -keystore keystore.p12

# List what's in the keystore using the keytool
keytool -list -keystore keystore.p12

Keystore format

If you are using Java <=8, you should pass the additional parameter -storetype pkcs12 to the keytool commands in the example above.

Once the password is saved in the keystore, you can use its alias (e.g., database1 or database2 in the example above) to let PGX retrieve it.

First, you should register the keystore to the session that will be loading the graph through the registerKeystore(keystorePath, keystorePassword) API. The keystorePath parameter refers to a path on the client side, where the keystore with the desired password is located. The keystorePassword parameter is the password to unlock the keystore.

Once the keystore is registered to a session, that session can load graph data from the database by pointing to the keystore alias in the graph config, as the following excerpt shows.

{
  "jdbc_url": "jdbc:oracle:thin:@localhost:1521:rdbmsod",
  "format": "two_tables",
  "datastore": "rdbms",
  "username": "scott",
  "keystore_alias": "database1",
  "edge_props": [{
     "name": "EPROP0",
     "type": "int"
  }]
}