This is the seventh day of my participation in the First Challenge 2022
1. Install Neo4j
The following is the official document: neo4j.com/download/ After downloading from the above website, remember the pop-up key, which will be used for subsequent software activation.
Two, basic use method
- New project
2. Change the project name
- Create a local or remote database
- Starting a local database
- Use Neo4j Broswer to operate
Node operation
- Create a node
Create (: university {name:" Xidian University "})Copy the code
- View the constructed node diagram
- Adjust the font size of the node display
- Get all nodes
match(n) return (n)
Copy the code
The following focuses on how to use Py2neo to operate Neo4j.
- Query node
created_node = matcher[node_id]
print(created_node)
Copy the code
- Conditional query
matcher.match('Judgment instrument').where(name = 'XXX Criminal Judgment ').first()
Copy the code
- Returns a node that matches the condition
temp = selector.match('Person').first()
Copy the code
- Adds and modifies node attribute values
temp['name'] = '001'
Copy the code
- labeling
temp.add_label('case')
graph.push(temp)
Copy the code
- Remove nodes
graph.delete(node)
Copy the code
- Create a node
node = Node('people', name = 'Joe')
graph.create(node)
Copy the code
Connect to the database using Py2neo
from py2neo import Graph,Node,Relationship,Subgraph
from py2neo.matching import *
graph = Graph("bolt://localhost:7687", auth=("neo4j"."1234"))
success = graph.run("UNWIND range(1, 3) AS n RETURN n, n * n as n_sq")
if (success):
print("Connection successful")
Copy the code
conclusion
Py2neo is a python third-party library that operates on Neo4j. It can be queried and used at the same time.
Reference documentation
-
Use Py2neo to add, delete, modify and check Neo4j data: nodes
-
Neo4j-applic Py2neo tutorial with Python
-
Simple Use of Py2neo (1)