Neo4j Server: Graph

Bulbs API for the Neo4j Server Graph.

Graph

class bulbs.neo4jserver.graph.Graph(config=None)[source]

The primary interface to Neo4j Server.

Instantiates the database Client object using the specified Config and sets up proxy objects to the database.

Parameters:

config (bulbs.config.Config) – Optional. Defaults to the default config.

Variables:
  • client_class – Neo4jClient class.
  • default_index – Default index class.
  • client – Neo4jClient object.
  • vertices – VertexProxy object.
  • edges – EdgeProxy object.
  • config – Config object.
  • gremlin – Gremlin object.
  • scripts – GroovyScripts object.

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)
client_class

alias of Neo4jClient

default_index

alias of ExactIndex

set_metadata(key, value)[source]

Sets the metadata key to the supplied value.

Parameters:
  • key (str) – Metadata key
  • value (str, int, or list) – Metadata value.
Return type:

Neo4jResponse

get_metadata(key, default_value=None)[source]

Returns the value of metadata for the key.

Parameters:
  • key (str) – Metadata key
  • default_value (str, int, or list) – Default value to return if the key is not found.
Return type:

Neo4jResult

remove_metadata(key)[source]

Removes the metadata key and value.

Parameters:key (str) – Metadata key
Return type:Neo4jResponse
load_graphml(uri)[source]

Loads a GraphML file into the database and returns the response.

Parameters:uri (str) – URI of the GraphML file to load.
Return type:Neo4jResult
get_graphml()[source]

Returns a GraphML file representing the entire database.

Return type:Neo4jResult
warm_cache()[source]

Warms the server cache by loading elements into memory.

Return type:Neo4jResult
clear()[source]

Deletes all the elements in the graph.

Return type:Neo4jResult

WARNING

This will delete all your data!

E

Returns a list of all the edges in the graph.

Return type:list or None
V

Returns a list of all the vertices in the graph.

Return type:list or None
add_proxy(proxy_name, element_class, index_class=None)

Adds an element proxy to the Graph object for the element class.

Parameters:
  • proxy_name (str) – Attribute name to use for the proxy.
  • element_class (Element) – Element class managed by this proxy.
  • index_class (Index) – Index class for Element’s primary index. Defaults to default_index.
Return type:

None

build_proxy(element_class, index_class=None)

Returns an element proxy built to specifications.

Parameters:
  • element_class (Element) – Element class managed by this proxy.
  • index_class (Index) – Optional Index class for Element’s primary index. Defaults to default_index.
Return type:

Element proxy