Browse files

code macro

  • Loading branch information...
1 parent 172aed7 commit 4bafca65619dd3ca028d287b2648201b45040930 @nigelsmall committed May 6, 2012
Showing with 19 additions and 0 deletions.
  1. +19 −0 tutorials/01.getting_started.creole
View
19 tutorials/01.getting_started.creole
@@ -9,3 +9,22 @@ from py2neo import neo4j
graph_db = neo4j.GraphDatabaseService("http://localhost:7474/db/data/")
}}}
+Once a connection has been established, nodes can be added to the graph using one of several methods. To create a single node, the {{{create_node}}} method can be used. If more than one node needs to be added, it is more efficient to use the batch creation method {{{create_nodes}}}. Finally, a Cypher {{{CREATE}}} statement can also be used. The code below illustrates these three node creation methods:
+
+<<code lang="python">>
+# create one node
+a = graph_db.create_node({"name": "Alice"})
+
+# create several nodes at once
+b, c = graph_db.create_nodes(
+ {"name": "Bob"},
+ {"name": "Carol"}
+}
+
+# create a node using Cypher
+from py2neo import cypher
+query = "create d = {name: 'Dave'} return d"
+data, metadata = cypher.execute(graph_db, query)
+d = data[0][0]
+<</code>>
+

0 comments on commit 4bafca6

Please sign in to comment.