How to add a list in Neo4j python-embedded?

I am trying to make a graph in Neo4j python-embedded using these documents: http://docs.neo4j.org/chunked/snapshot/python-embedded-reference-core.html "Valid property values ​​include strings, numbers, booleans, and also arrays of these primitives. " So, I am trying to create a list of strings and then add a list.

from neo4j import GraphDatabase
db = GraphDatabase('/home/username/Neo4j/')
with db.transaction:
    testNode = db.node()
    testNode['stringList'] = ["one","two"]
    string_list_edit = testNode['stringList']
    string_list_edit.append("three")

Gives me this error:

AttributeError: 'java.lang.String[]' object has no attribute 'append'

How it's done?

+3
source share
2 answers

If you embed all of your code, you can evaluate it for other errors. Check out the docs: http://docs.neo4j.org/chunked/snapshot/python-embedded-reference-core.html

Do you turn on

with db.transactions:

Up to your code? You have to do it. Also try the following:

testNode['stringList'] = ["one","two"]
string_list_edit = testNode['stringList']
string_list_edit.append("three")
testNode['stringList'] = string_list_edit
+1

, . append().

? , - ( "java.lang.String []" - String Java) Java Python, Python.

string_list_edit = list(testNode['stringList'])
string_list_edit.append("three")

, -.

, += - , append Python - , , += string_list_edit = string_list_edit + "three" , , string_list_edit = string_list_edit + ["three"], , .

- print type(testNode['stringList']) .

+1

All Articles