Adding Nodes to Neo4j Graph

suggest change
results = News.objects.todays_news()
for r in results:
    article = graph.merge_one("NewsArticle", "news_id", r)
    article.properties["title"] = results[r]['news_title']
    article.properties["timestamp"] = results[r]['news_timestamp']
    article.push()
    [...]

Adding nodes to the graph is pretty simple,graph.merge_one is important as it prevents duplicate items. (If you run the script twice, then the second time it would update the title and not create new nodes for the same articles)

timestamp should be an integer and not a date string as neo4j doesnt really have a date datatype. This causes sorting issues when you store date as ‘05-06-1989’

article.push() is an the call that actually commits the operation into neo4j. Dont forget this step.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Neo4j:
* Adding Nodes to Neo4j Graph

Table Of Contents
2 Filter
3 List
7 Loops
22 Reduce
27 Classes
31 Set
42 Tuple
45 Enum
62 Sockets
89 urllib
92 Idioms
104 Stack
105 Profiling
109 Logging
111 os module
118 Mixins
120 ArcPy
126 Arrays
132 2to3 tool
135 Unicode
138 Neo4j
140 Curses
141 Templates
145 heapq
146 tkinter
154 Audio
155 pyglet
157 ijson
160 Flask
161 Groupby
163 pygame
165 hashlib
166 Gzip
167 ctypes
185 pyaudio
186 shelve