Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🤖 Sandbox code update #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions code/graphql/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type Other {
valid_until: String!
intermediary_of: [Entity]
@relationship(type: "intermediary_of", direction: OUT)
same_name_as: [Entity] @relationship(type: "SAME_NAME_AS", direction: OUT)
}

type Intermediary {
Expand All @@ -55,6 +56,7 @@ type Intermediary {
sourceID: String!
valid_until: String!
connected_to: [Entity] @relationship(type: "connected_to", direction: OUT)
same_name_as: [Entity] @relationship(type: "SAME_NAME_AS", direction: OUT)
}

type Officer {
Expand All @@ -69,6 +71,8 @@ type Officer {
@relationship(type: "registered_address", direction: OUT)
officer_of: [Entity] @relationship(type: "officer_of", direction: OUT)
connected_to: [Entity] @relationship(type: "connected_to", direction: OUT)
same_name_as: [Entity] @relationship(type: "SAME_NAME_AS", direction: OUT)
same_id_as: [Officer] @relationship(type: "SAME_ID_AS", direction: OUT)
num_of_connected_entities: Int
@cypher(
statement: """
Expand Down
2 changes: 1 addition & 1 deletion code/javascript/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const neo4j = require('neo4j-driver');
const driver = neo4j.driver('neo4j://<HOST>:<BOLTPORT>',
neo4j.auth.basic('<USERNAME>', '<PASSWORD>'),
{/* encrypted: 'ENCRYPTION_OFF' */});
{});

const query =
`
Expand Down
24 changes: 11 additions & 13 deletions code/python/example.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
# pip3 install neo4j-driver
# pip3 install neo4j
# python3 example.py

from neo4j import GraphDatabase, basic_auth

driver = GraphDatabase.driver(
"neo4j://<HOST>:<BOLTPORT>",
auth=basic_auth("<USERNAME>", "<PASSWORD>"))

cypher_query = '''
MATCH (a:Officer {name:$name})-[r:officer_of|intermediary_of|registered_address*..10]-(b)
RETURN b.name as name LIMIT 20
'''

with driver.session(database="neo4j") as session:
results = session.read_transaction(
lambda tx: tx.run(cypher_query,
name="Ross, Jr. - Wilbur Louis").data())
for record in results:
print(record['name'])

driver.close()
with GraphDatabase.driver(
"neo4j://<HOST>:<BOLTPORT>",
auth=("<USERNAME>", "<PASSWORD>")
) as driver:
result = driver.execute_query(
cypher_query,
name="Ross, Jr. - Wilbur Louis",
database_="neo4j")
for record in result.records:
print(record['name'])