py2neo.client.bolt – Low-level Bolt client for Neo4j

This module contains client implementations for the Bolt messaging protocol. It contains a base Bolt class, which is a type of Connection, and which is further extended by a separate class for each protocol version. Bolt1 extends Bolt, Bolt2 extends Bolt1, and so on.

Each subclass therefore introduces deltas atop the previous protocol version. This reduces duplication of client code at the expense of more work should an old protocol version be removed.

As of Bolt 4.0, the protocol versioning scheme aligned directly with that of Neo4j itself. Prior to this, the protocol was versioned with a single integer that did not necessarily increment in line with each Neo4j product release.

class py2neo.client.bolt.Bolt(wire, profile, user_agent, on_bind=None, on_unbind=None, on_release=None)[source]

This is the base class for Bolt client connections. This class is not intended to be instantiated directly, but contains an open() factory method that returns an instance of the appropriate subclass, once a connection has been successfully established.

property broken

True if the connection has been broken by the server or network.

close()[source]

Close the connection.

property closed

True if the connection has been closed by the client.

classmethod open(profile, user_agent=None, on_bind=None, on_unbind=None, on_release=None)[source]

Open a Bolt connection to a server.

Parameters
  • profileConnectionProfile detailing how and where to connect

  • user_agent

  • on_bind

  • on_unbind

  • on_release

supports_multi()[source]

Detect whether or not this connection supports multi-database.

class py2neo.client.bolt.Bolt1(wire, profile, user_agent, on_bind=None, on_unbind=None, on_release=None)[source]
begin(graph_name, readonly=False, after=None, metadata=None, timeout=None)[source]

Begin a transaction.

Parameters
  • graph_name

  • readonly

  • after

  • metadata

  • timeout

Returns

new Transaction object

Raises

TransactionError – if a new transaction cannot be created

sync(result)[source]

Perform network synchronisation required to make available a given result.

class py2neo.client.bolt.Bolt2(wire, profile, user_agent, on_bind=None, on_unbind=None, on_release=None)[source]
class py2neo.client.bolt.Bolt3(wire, profile, user_agent, on_bind=None, on_unbind=None, on_release=None)[source]
begin(graph_name, readonly=False, after=None, metadata=None, timeout=None)[source]

Begin a transaction.

Parameters
  • graph_name

  • readonly

  • after

  • metadata

  • timeout

Returns

new Transaction object

Raises

TransactionError – if a new transaction cannot be created

class py2neo.client.bolt.Bolt4x0(wire, profile, user_agent, on_bind=None, on_unbind=None, on_release=None)[source]
exception py2neo.client.bolt.BoltProtocolError[source]
class py2neo.client.bolt.BoltResult(graph_name, cx, response)[source]

The result of a query carried out over a Bolt connection.

Implementation-wise, this form of query is comprised of a number of individual message exchanges. Each of these exchanges may succeed or fail in its own right, but contribute to the overall success or failure of the query.

class py2neo.client.bolt.BoltTransaction(graph_name, protocol_version, readonly=False, after=None, metadata=None, timeout=None)[source]