I am connected to a database named ‘testdb’ using the PSQL utility with the ‘age’ extension loaded, How can I retrieve all the details(vertexes, relationship) of all graphs available in a database and also the number of graphs present in apache age?
I know using the query:
SELECT * FROM ag_catalog.ag_graph;
we can retrieve all the graph names but I need to access all vertex and relationships in each graph as well.
3
Answers
Try using these SQL statements:
SELECT * FROM age_graph.vertex;
To get the vertices of the graph.SELECT * FROM age_graph.edge;
To get the edges.I hope this was of help.
For a given graph, you can extract vertices and edges using 2 cypher queries.
For Vertices
For Edges
ELSE you can execute a single cypher query with multiple returns to get the desired output.
You can try using the python driver or any other AGE driver to execute this easily. You can simply fetch all the graph names using :
and then execute above cypher queries iteratively over different graph names.
You could use
SELECT * FROM ag_catalog.ag_label
to view information about the vertices and edges in all your graphs, this should output something like this:As you can see, the above contains the information of all the nodes and edges of all your graphs. You can see that the vertices are labeled ‘v’ and the edges are labeled ‘e’.
So from this you could run a query like;
And you will get the details of the relationship ‘Friends’;
Overall I think running
SELECT * FROM ag_label;
will really give you a view of all the nodes and egdes in all your graphs.