DBIO::PostgreSQL::Age
Apache AGE graph database extension support for DBIO::PostgreSQL.
Supports
- Apache AGE openCypher graph queries (DBIO::PostgreSQL::Age::Storage)
- graph creation and deletion lifecycle
- cypher() SQL function execution via DBIO::PostgreSQL::Age::Storage/cypher
- integration with DBIO::PostgreSQL base driver
Usage
package MyApp::Schema;
use base 'DBIO::Schema';
__PACKAGE__->load_components('PostgreSQL::Age');
my $schema = MyApp::Schema->connect(
$dsn, $user, $pass,
{ on_connect_call => 'load_age' },
);
$schema->storage->create_graph('social');
my $rows = $schema->storage->cypher(
'social',
'MATCH (a:Person)-[:KNOWS]->(b:Person) RETURN a.name, b.name',
[qw( person friend )],
);
DBIO core autodetects dbi:Pg: DSNs with the PostgreSQL driver, and
DBIO::PostgreSQL::Age is loaded via load_components.
Apache AGE Features
Graph Operations
create_graph($name)- create a named graphdrop_graph($name)- drop a graph (cascade)cypher($graph, $query, \@params)- execute openCypher query
openCypher Support
MATCH,OPTIONAL MATCH- graph pattern matchingWHERE- filtering on node/relationship propertiesRETURN,RETURN DISTINCT- result projectionORDER BY,SKIP,LIMIT- paginationWITH- query chainingCREATE,SET- graph mutationDELETE,DETACH DELETE- graph deletion- Node labels and relationship types
Labels & Types
- Node labels:
(:Person),(:Person {name: 'Alice'}) - Relationship types:
[:KNOWS],[:KNOWS {since: 2020}] - Multiple labels:
(:Person:Employee) - Multiple relationships:
(a)-[:KNOWS]->(b)-[:WORKS_WITH]->(c)
Testing
Requires a running PostgreSQL instance with Apache AGE extension:
export DBIO_TEST_PG_DSN="dbi:Pg:database=myapp"
export DBIO_TEST_PG_USER=postgres
export DBIO_TEST_PG_PASS=secret
prove -l t/
The live test (C<t/10-age-live.t>) creates an actual graph and runs openCypher queries. Skips if no AGE extension is available.
Requirements
- Perl 5.36+
- DBD::Pg
- Apache AGE PostgreSQL extension
- DBIO core
- DBIO::PostgreSQL base driver
See Also
DBIO::PostgreSQL, DBIO::PostgreSQL::Age::Storage, Apache AGE