30.3 Exporting Graphs Into a File
The graph server (PGX) allows the client to export a partitioned graph that is loaded into the graph server (PGX) into a file.
You can use the store() method to store the graph in CSV format. You
can also dynamically select the set of properties to be stored with the graph, that is,
not all the properties need to be exported.
When PGX exports the specified graph into a file, PGX also creates a
GraphConfig which is returned to the client. Using this
GraphConfig, you can load the created graph instance later.
Consider the following example where a graph is first loaded into memory. It is then stored with all its original vertex and edge properties as a file in CSV format, on disk. When a graph is stored, you need to specify the graph format, a path where the file should be stored, the properties to store and a flag that specifies whether or not a file should be overwritten should a file with the same name already exist.
opg4j> var g = session.readGraphByName("BANK_GRAPH", GraphSource.PG_SQL)
opg4j> var config = g.store(ProviderFormat.CSV, "/tmp/PG", VertexProperty.ALL, EdgeProperty.ALL, true)PgxGraph g = session.readGraphByName("BANK_GRAPH", GraphSource.PG_SQL);
GraphConfig config = g.store(ProviderFormat.CSV, "/tmp/PG", VertexProperty.ALL, EdgeProperty.ALL, true);g =session.read_graph_by_name("BANK_GRAPH", "pg_sql")
config = g.store('csv', '/tmp/PG', vertex_properties=True, edge_properties=True, overwrite=True)Parent topic: Working with Files Using the Graph Server (PGX)