Create a gist now

Instantly share code, notes, and snippets.

Bulbs 0.3 Neo4j Server Example
from bulbs.config import Config
from bulbs.gremlin import Gremlin
from bulbs.model import Node, NodeProxy
from import String, Integer
from bulbs.element import Vertex, VertexProxy, EdgeProxy, Edge
from bulbs.neo4jserver import Neo4jResource, NEO4J_URI, \
VertexIndexProxy, EdgeIndexProxy, ExactIndex
class Person(Node):
element_type = "person"
name = String(nullable=False)
age = Integer()
class Whybase(object):
def __init__(self):
self.config = Config(NEO4J_URI)
self.resource = Neo4jResource(self.config)
self.gremlin = Gremlin(self.resource)
self.indicesV = VertexIndexProxy(ExactIndex,self.resource)
self.indicesE = EdgeIndexProxy(ExactIndex,self.resource)
self.vertices = VertexProxy(Vertex,self.resource)
self.vertices.index = self.indicesV.get_or_create("vertices")
self.edges = EdgeProxy(Edge,self.resource)
self.edges.index = self.indicesE.get_or_create("edges")
self.people = NodeProxy(Person,self.resource)
self.people.index = self.indicesV.get_or_create("person")
whybase = Whybase()
james = whybase.people.create(name="James Thornton",age=34)
print james.eid,, james.age = "James William Thornton" = "Dallas"
print james.eid,, james.age,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment