py2neo

py2neo return number of nodes and relationships created

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 09:53:46
问题 I need to create a python function such that it adds nodes and relationship to a graph and returns the number of created nodes and relationships. I have added the nodes and relationship using graph.cypher.execute(). arr_len = len(dic_st[story_id]['PER']) for j in dic_st[story_id]['PER']: graph.cypher.execute("MERGE (n:PER {name:{name}})",name = j[0].upper()) #creating the nodes of PER in the story print j[0] for j in range(0,arr_len): for k in range(j+1,arr_len): graph.cypher.execute("MATCH

Creating unique relationships without creating unique nodes in neo4j

落爺英雄遲暮 提交于 2019-12-11 09:23:49
问题 I am breaking out a question I asked elsewhere into a second part. For a given node which has an id_str that is known to be in the graph, I have a list of new id_str that may or may not be in the graph. If they /are/ in the graph, I would like to create unique relationships to them. (If they are not, I want to ignore them.) My current method is quite slow. I am doing the looping part outside of Neo, using py2neo and writing the entries one at a time using a very slow filter. Originally, I was

ModuleNotFoundError: No module named 'neo4j.addressing' and ModuleNotFoundError: No module named 'neo4j'

南楼画角 提交于 2019-12-11 05:17:38
问题 I am getting this error. just from trying to run Graph() method. >>> import py2neo >>> graph = py2neo.Graph() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "E:\Chibanggri\flask and neo4j\venv\lib\site-packages\py2neo\database.py", line 305, in __new__ database = Database(uri, **settings) File "E:\Chibanggri\flask and neo4j\venv\lib\site-packages\py2neo\database.py", line 85, in __new__ connection_data = get_connection_data(uri, **settings) File "E:\Chibanggri

Query writing performance on neo4j with py2neo

心已入冬 提交于 2019-12-11 03:14:58
问题 Currently im struggle on finding a performant way, running multiple queries with py2neo. My problem is a have a big list of write queries in python that need to be written to neo4j. I tried multiple ways to solve the issue right now. The best working approach for me was the following one: from py2neo import Graph queries = ["create (n) return id(n)","create (n) return id(n)",...] ## list of queries g = Graph() t = graph.begin(autocommit=False) for idx, q in enumerate(queries): t.run(q) if idx

Inserting large graph data into Neo4j using py2neo WriteBatch

你离开我真会死。 提交于 2019-12-10 19:59:28
问题 I have a graph represented by the following files: VertexLabel.txt -> each line contains properties for each vertex. EdgeLabel.txt -> each line contains properties for each edge. EdgeID.txt -> each line contains 3 separated integers which correspond to indexes in the label files: source_index target_index edge_index. There are roughly 44K vertices with 240K edges. I'm trying to use neo4j.Writebatch to batch insert the graph data. from py2neo import Graph, neo4j, node, rel graph_db = Graph()

Increase Heap Space Available for JVM: OutOfMemoryError: Requested array size exceed VM limit Ubuntu 64Bit Neo4j 2.0

本小妞迷上赌 提交于 2019-12-10 11:54:08
问题 My specs: -Ubuntu 64bit -Neo4j 2.0 -32 GB of Ram -AMD FX-8350 Eight COre Processor The problem: I'm making a request to my Neo4j server with the following query: MATCH (being:my_label_2) RETURN being And gives me this error: OutOfMemoryError Requested array size exceeds VM limit StackTrace: java.lang.StringCoding$StringEncoder.encode(StringCoding.java:300) java.lang.StringCoding.encode(StringCoding.java:344) java.lang.String.getBytes(String.java:916) org.neo4j.server.rest.repr.OutputFormat

How to combine cypher queries into a transaction in Py2neo v3

别来无恙 提交于 2019-12-10 10:23:24
问题 In py2neo v2.0, it was possible to use a transaction to execute Cypher statements: tx=graph.cypher.begin() tx.append("MERGE (n:Process {proc_nm : {proc_nm}}) ON CREATE SET n.count = 1 ON MATCH SET n.count = n.count +1", {proc_nm : 'wibble'}) tx.commit When processing complex files this allows very fast updates to be made to the Neo4J database. In py2neo v3.0 the syntax has changed to: graph.run(("MERGE (n:Process {proc_nm : {proc_nm}}) ON CREATE SET n.count = 1 ON MATCH SET n.count = n.count

Neo4j Python py2neo authorization error

若如初见. 提交于 2019-12-10 10:16:02
问题 Installed Neo4j 2.2.3 on Windows 8.1. Nothing special. Started the server through the Neo4j start app. Nothing special Started working with py2neo as in the documentation on Neo4j.org. Ran into an authorization error I cannot explain. Log follows below. One special remark: in spite of python\script being in the path the python shell will only start from C:\python34\python. Please explain what I'm doing wrong and can improve. The Log: Microsoft Windows [Version 6.3.9600] (c) 2013 Microsoft

Slow performance bulk updating relationship properties in Neo4j

孤者浪人 提交于 2019-12-10 09:33:30
问题 I'm struggling to efficiently bulk update relationship properties in Neo4j. The objective is to update ~ 500,000 relationships (each with roughly 3 properties) which I chunk into batches of 1,000 and processing in a single Cypher statement, UNWIND {rows} AS row MATCH (s:Entity) WHERE s.uuid = row.source MATCH (t:Entity) WHERE t.uuid = row.target MATCH (s)-[r:CONSUMED]->(t) SET r += row.properties however each batch of 1,000 nodes takes around 60 seconds. There exists an index on UUID property

How to convert neo4j return types to python types

女生的网名这么多〃 提交于 2019-12-08 07:26:30
问题 I am using py2neo and I would like to extract the information from query returns so that I can do stuff with it in python. For example, I have a DB containing three "Person" nodes: for num in graph.cypher.execute("MATCH (p:Person) RETURN count(*)"): print num outputs: >> count(*) 3 Sorry for shitty formatting, it looks essentially the same as a mysql output. However, I would like to use the number 3 for computations, but it has type py2neo.cypher.core.Record . How can I convert this to a