Created
February 8, 2012 21:28
-
-
Save espeed/1774019 to your computer and use it in GitHub Desktop.
Bulbs 0.3 Neo4j Server Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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