[英]AttributeError: 'Graph' object has no attribute 'cypher' in migration of data from Postgress to Neo4j(Graph Database)
I am working on migration of data from postgres to Graph Database manually. 我正在努力将数据从postgres手动迁移到Graph Database。
I have wrote script below: 我写了下面的脚本:
import psycopg2
from py2neo import authenticate, Graph
authenticate("localhost:7474", "neo4j", "password")
n4j_graph = Graph("http://localhost:7474/db/data/")
try:
conn=psycopg2.connect("dbname='db_name' user='user' password='password'")
except:
print "good bye"
cur = conn.cursor()
try:
cur.execute("""SELECT * from table_name""")
except:
print "not found"
rows = cur.fetchall()
for row in rows:
username = row[4]
email = row[7]
s = '''MERGE (u:User { username: "%(username)s"}) MERGE (e:Email { email: "%(email)s"}) CREATE UNIQUE (u)-[:BELONGS_TO]->(e)''' %{"username": username, "email": email}
print s
n4j_graph.cypher.execute(s)
Error: 错误:
AttributeError: 'Graph' object has no attribute 'cypher'
AttributeError:'Graph'对象没有属性'cypher'
This issue I resolved by updating py2neo to version 2.0.8. 这个问题我通过将py2neo更新到2.0.8版来解决。
pip uninstall py2neo
pip install py2neo==2.0.8
I am following documentation of py2neo . 我正在关注py2neo的文档。
While for production I am still getting: 对于生产我仍然得到:
AttributeError: 'Graph' object has no attribute 'cypher'
AttributeError:'Graph'对象没有属性'cypher'
GET 404 response
获得404回应
What can be issue? 有什么问题?
I had this problem too. 我也有这个问题。 In my case I was looking at the py2neo v2 documentation but on my machine was installed py2neo v3 .
在我的情况下,我正在查看py2neo v2文档,但在我的机器上安装了py2neo v3 。 You should check your py2neo version and replace .cyper( {query} ) with .run( {query} )
您应检查py2neo版本和替换.cyper({查询})与.RUN({查询})
The previous version of py2neo allowed Cypher execution through Graph.cypher.execute().
先前版本的py2neo允许Cypher通过Graph.cypher.execute()执行。 This facility is now instead accessible via Graph.run() and returns a lazily-evaluated Cursor rather than an eagerly-evaluated RecordList.
现在可以通过Graph.run()访问此工具,并返回一个延迟评估的Cursor,而不是一个热切评估的RecordList。
I have resolved issue. 我已经解决了问题。 Issue was with version of
py2neo
. 问题是
py2neo
版本。 I have installed version 3 while version 2.08 is latest in V2. 我安装了版本3,而版本2.08是V2的最新版本。
py2neo allowed Cypher execution through Graph.cypher.execute()
. py2neo允许Cypher通过
Graph.cypher.execute()
执行。
pip uninstall py2neo
pip install py2neo==2.0.8
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.