Skip to content

Instantly share code, notes, and snippets.

@espeed
Created February 8, 2012 21:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save espeed/1774019 to your computer and use it in GitHub Desktop.
Save espeed/1774019 to your computer and use it in GitHub Desktop.
Bulbs 0.3 Neo4j Server Example
# Bulbs 0.3 Neo4j Server Example
# by James Thornton (http://jamesthornton.com)
from bulbs.neo4jserver import Graph
from bulbs.model import Node, Relationship
from bulbs.property import String, Integer, DateTime
from bulbs.utils import current_datetime
class Person(Node):
element_type = "person"
name = String(nullable=False)
age = Integer()
class Knows(Relationship):
label = "knows"
timestamp = DateTime(default=current_datetime, nullable=False)
g = Graph()
g.add_proxy("people", Person)
g.add_proxy("knows", Knows)
james = g.people.create(name="James",age=34)
julie = g.people.create(name="Julie")
knows = g.knows.create(james,julie)
print type(james), james.eid, james.element_type, james.name, james.age
james.name = "James Thornton"
james.city = "Dallas"
james.save()
james2 = g.people.get(james.eid)
print james2.city
friends = james.outV('knows')
print list(friends)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment