The source code is as follows
Error message:
An error is reported from graph.run, and a JSon-related error is reported, which is puzzling.
Traceback (most recent call last):
File "D:\software\Python\Python37\lib\site-packages\py2neo\client\http.py", line 443, in from_json
content = json_loads(data, object_hook=JSONHydrant.json_to_packstream)
File "D:\software\Python\Python37\lib\json\__init__.py", line 361, in loads
return cls(**kw).decode(s)
File "D:\software\Python\Python37\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "D:\software\Python\Python37\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Solution:
You need to add a name="neo4j" to succeed, as follows
graph = Graph("http://localhost:7474",user= "neo4j",password = "zhang123",name="neo4j")
or this
graph = Graph("http://localhost:7474",auth=("neo4j","zhang123"),name="neo4j")
complete demo
from py2neo import Graph
#连接图数据库
graph = Graph("http://localhost:7474",user= "neo4j",password = "zhang123",name="neo4j")
cypher = "create (n:person {name : '老大',age : 18,length : 168})"
graph.run(cypher)