Loading a Graph from Two Database Tables

Creating graph configuration

To load this graph into PGX, write a graphconfig. You can write the config in JSON format into a file:

Notice that you will have to modify jdbc_url, username and password according to your own database configuration.

 1# To load this graph into PGX, write a graph config.
 2# You can write the config in JSON format into a file
 3json = '''{
 4    "format": "two_tables",
 5    "datastore": "rdbms",
 6    "jdbc_url": "jdbc:oracle:thin:@localhost:1521:rdbmsod",
 7    "username": "username",
 8    "password": "password",
 9    "keystore_alias": "database1",
10    "nodes_table_name": "nodes",
11    "edges_table_name": "edges",
12    "error_handling": {
13        "on_prop_conversion": "silent",
14        "on_missed_prop_key": "log_warn_once"
15    }
16}'''

Actual Graph Loading

To load the graph data from the two tables into memory, simply write the graph config to read_graph_with_properties(). You can either write the path to the JSON file:

1# To load the graph data from the two tables into memory
2# You can either write the path to the JSON file:
3session = pypgx.get_session()
4path = self.pgx_test_resources + "/graph-confs/sample.csv.gz.json"
5graph = session.read_graph_with_properties(path)

or the config object directly if you built the config programmatically:

1session = pypgx.get_session("my-session")
2graph = session.read_graph_with_properties(config)