Skip to content

Commit

Permalink
Updated Cypher
Browse files Browse the repository at this point in the history
  • Loading branch information
MontyBitto committed May 7, 2024
1 parent a5dd0d5 commit 4b51a0c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 109 deletions.
1 change: 0 additions & 1 deletion manual/_quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ book:
- architecture.qmd
- usage.qmd
- cypher.qmd
- queries.qmd
- sparql.qmd
page-footer:
right:
Expand Down
33 changes: 32 additions & 1 deletion manual/cypher.qmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: Cypher-Einführung
title: Abfragen mit Cypher
lang: de
execute:
echo: false
---

### Nodes
Expand Down Expand Up @@ -44,3 +46,32 @@ RETURN p
```

Auch Pfade können einer Variable zugewiesen werden. Hier wird der vollständige Pfad ausgegeben.

## Beispielabfragen

Finde Wert, Einheit und Notiz aller Messungen.

```cypher
MATCH (n:E16_Measurement)-[:P40_observed_dimension]->(m:E54_Dimension)-[:P2_has_type]->(:E55_Type)-[:P48_has_preferred_identifier]->(l)
MATCH (m)-[:P91_has_unit]->(:E58_Measurement_Unit)-[:P48_has_preferred_identifier]->(o)
RETURN m.P90_has_value AS value, o.P3_has_note AS unit, l.P3_has_note AS note
```

```{python}
from neo4j import GraphDatabase
import json
with open('neo4j.json', 'r') as file:
neo4j_login = json.loads(file.read())
uri = neo4j_login.get("uri")
user = neo4j_login.get("user")
password = neo4j_login.get("password")
cmd = "MATCH (n:E16_Measurement)-[:P40_observed_dimension]->(m:E54_Dimension)-[:P2_has_type]->(:E55_Type)-[:P48_has_preferred_identifier]->(l) MATCH (m)-[:P91_has_unit]->(:E58_Measurement_Unit)-[:P48_has_preferred_identifier]->(o) RETURN m.P90_has_value AS value, o.P3_has_note AS unit, l.P3_has_note AS note;"
driver = GraphDatabase.driver(uri, auth=(user, password))
with driver.session() as session:
for x in session.run(cmd):
print(','.join((str(x) for x in x.values())))
```

## Weitere Informationen

[Das englische Cypher Handbuch](https://neo4j.com/docs/cypher-manual/current/)
107 changes: 0 additions & 107 deletions manual/queries.qmd

This file was deleted.

0 comments on commit 4b51a0c

Please sign in to comment.