Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Bulbs 0.3 Neo4j Server Example

View bulbs03_example.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
from bulbs.config import Config
from bulbs.gremlin import Gremlin
from bulbs.model import Node, NodeProxy
from bulbs.property 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.name, james.age
 
james.name = "James William Thornton"
james.city = "Dallas"
james.save()
 
print james.eid, james.name, james.age, james.city
 
 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.