Bulbs API¶
Bulbs is an open-source Python library and persistence framework for graph databases. It connects to Rexster, which provides access to any Blueprints-enabled graph database, including: TinkerGraph, Neo4j, OrientDB, Dex, and OpenRDF Sail.
Graph¶
- class bulbs.neo4jserver.graph.Neo4jGraph(root_uri='http://localhost:7474/db/data/')[source]¶
The primary interface to graph databases on the Rexster REST server.
Instantiates the database Resource object using the specified database URL and sets up proxy objects to the database.
Parameters: root_uri – The URI to Neo4j Server. Example:
>>> from bulbs.neo4jserver import Graph >>> g = Graph() >>> james = g.vertices.create({'name':'James'}) >>> julie = g.vertices.create({'name':'Julie'}) >>> g.edges.create(james,"knows",julie) >>> g.vertices.index.lookup(name="James")
Vertices¶
- class bulbs.element.Vertex(resource)[source]¶
A container for Vertex elements returned by the resource.
- map()¶
Returns a dict of the element’s data that’s stored in the DB.
Edges¶
- class bulbs.element.Edge(resource)[source]¶
A container for Edge elements returned by the resource.
- map()¶
Returns a dict of the element’s data that’s stored in the DB.
Indices¶
- class bulbs.index.Index(resource, results)[source]¶
Abstract base class for the default index.
- resource = None¶
The Resource object for the database.
- results = None¶
The index attributes returned by the proxy request.
- put(_id, key=None, value=None, **pair)[source]¶
Put an element into the index at key/value and return the response.
- put_unique(_id, key=None, value=None, **pair)[source]¶
Put an element into the index at key/value and overwrite it if an element already exists at that key and value; thus, there will be a max of 1 element returned for that key/value pair. Return Rexster’s response.
- get(key=None, value=None, **pair)[source]¶
Return all the elements in the index with property key equal to value.
- get_unique(key=None, value=None, **pair)[source]¶
Returns a max of 1 elements matching the key/value pair in the index.
- class bulbs.index.VertexIndexProxy(index_class, resource)[source]¶
Abstract base class the vertex index proxy.
- index_class = None¶
The index class for this proxy, e.g. ExactIndex.
- resource = None¶
The Resource object for the database.
Gremlin¶
- class bulbs.gremlin.Gremlin(resource)[source]¶
An interface for executing Gremlin scripts on the resource.
Model¶
- class bulbs.model.Node(resource)[source]¶
-
- bothE(label=None)¶
Return all incoming and outgoing edges of the vertex.
- bothV(label=None)¶
Return all incoming- and outgoing-adjacent vertices of vertex.
- inE(label=None)¶
Return the incoming edges of the vertex.
- inV(label=None)¶
Return the in-adjacent vertices of the vertex.
- map()¶
Returns a dict of the element’s data that’s stored in the DB.
- outE(label=None)¶
Return the outgoing edges of the vertex.
- outV(label=None)¶
Return the out-adjacent vertices to the vertex.
Properties¶
- class bulbs.property.Property(name=None, fget=None, fset=None, fdel=None, default=None, onupdate=None, constraint=None, nullable=True, unique=False, index=False)[source]¶
Container for a graph-database property used to create Models.
- class bulbs.property.String(name=None, fget=None, fset=None, fdel=None, default=None, onupdate=None, constraint=None, nullable=True, unique=False, index=False)[source]¶
- python_type¶
alias of str
- validate(key, value)¶
Validates that Property data is of the right datatype before saving it to the DB and that the Property has a value if nullable is set to False.
- class bulbs.property.Integer(name=None, fget=None, fset=None, fdel=None, default=None, onupdate=None, constraint=None, nullable=True, unique=False, index=False)[source]¶
- python_type¶
alias of int
- validate(key, value)¶
Validates that Property data is of the right datatype before saving it to the DB and that the Property has a value if nullable is set to False.
- class bulbs.property.Long(name=None, fget=None, fset=None, fdel=None, default=None, onupdate=None, constraint=None, nullable=True, unique=False, index=False)[source]¶
- python_type¶
alias of long
- validate(key, value)¶
Validates that Property data is of the right datatype before saving it to the DB and that the Property has a value if nullable is set to False.
- class bulbs.property.Float(name=None, fget=None, fset=None, fdel=None, default=None, onupdate=None, constraint=None, nullable=True, unique=False, index=False)[source]¶
- python_type¶
alias of float
- validate(key, value)¶
Validates that Property data is of the right datatype before saving it to the DB and that the Property has a value if nullable is set to False.
- class bulbs.property.Null(name=None, fget=None, fset=None, fdel=None, default=None, onupdate=None, constraint=None, nullable=True, unique=False, index=False)[source]¶
- validate(key, value)¶
Validates that Property data is of the right datatype before saving it to the DB and that the Property has a value if nullable is set to False.
- class bulbs.property.List(name=None, fget=None, fset=None, fdel=None, default=None, onupdate=None, constraint=None, nullable=True, unique=False, index=False)[source]¶
- python_type¶
alias of list
- validate(key, value)¶
Validates that Property data is of the right datatype before saving it to the DB and that the Property has a value if nullable is set to False.
- class bulbs.property.Dictionary(name=None, fget=None, fset=None, fdel=None, default=None, onupdate=None, constraint=None, nullable=True, unique=False, index=False)[source]¶
- python_type¶
alias of dict
- validate(key, value)¶
Validates that Property data is of the right datatype before saving it to the DB and that the Property has a value if nullable is set to False.
Resource¶
- class bulbs.resource.Resource(config)[source]¶
Abstract base class for a server resource.
Parameters: config – Config object containing instance-specific configuration. - config = None¶
Config object containing instance-specific configuration.
- registery = None¶
Registry object to hold classes, proxies, indices, and scripts.
- remove_vertex(index_name, _id, key=None, value=None)[source]¶
Removes a vertex from the index and returns the Response.
- lookup_edge(index_name, key, value)[source]¶
Looks up an edge in the index and returns the Response.
- remove_edge(index_name, _id, key=None, value=None)[source]¶
Removes an edge from the index and returns the Response.
- create_indexed_vertex(data, index_name, keys=None)[source]¶
Creates a vertex, indexes it, and returns the Response.
- update_indexed_vertex(_id, data, index_name, keys=None)[source]¶
Updates an indexed vertex and returns the Response.
- create_indexed_edge(data, index_name, keys=None)[source]¶
Creates a edge, indexes it, and returns the Response.
Response¶
- class bulbs.resource.Response(response, config)[source]¶
Abstract base class for the response returned by the request.
Parameters: response – The raw response; its type will depend on the Resource. - result_class¶
alias of Result
- content = None¶
A dict containing the content returned in the response.
- raw = None¶
The raw response returned by the request.