您的位置:首页 > 移动开发 > Objective-C

AttributeError: 'Graph' object has no attribute 'cypher' in migration of data from Postgress to Neo4

2017-04-04 11:27 316 查看
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)


运行过程中发现错误如下:

AttributeError: 'Graph' object has no attribute 'cypher'

一番查找后才明白过来是我的pydev安装的版本不对,一次先卸载以前安装的版本,在安装我们需要使用的版本

pip uninstall py2neo
pip install py2neo==2.0.8
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐