Monitoring Client-Server Interaction

The function dumps log messages to standard output for various operations within the library.

To watch HTTP traffic:

>>> from py2neo import watch
>>> watch("httpstream")

To watch Cypher traffic:

>>> from py2neo import watch
>>> watch("py2neo.cypher")

To watch batch traffic:

>>> from py2neo import watch
>>> watch("py2neo.batch"), level=20, out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]

Escaping Values in Cypher

>>> from py2neo.cypher import cypher_escape
>>> rel_type = "KNOWS WELL"
>>> statement = "CREATE (a)-[ab:%s]->(b) RETURN ab" % cypher_escape(rel_type)
>>> statement
'CREATE (a)-[ab:`KNOWS WELL`]->(b) RETURN ab'

URI Rewriting

py2neo.rewrite(from_scheme_host_port, to_scheme_host_port)[source]

Automatically rewrite all URIs directed to the scheme, host and port specified in from_scheme_host_port to that specified in to_scheme_host_port.

As an example:

from py2neo import rewrite
# implicitly convert all URIs beginning with <http://localhost:7474>
# to instead use <https://dbserver:9999>
rewrite(("http", "localhost", 7474), ("https", "dbserver", 9999))

If to_scheme_host_port is None then any rewrite rule for from_scheme_host_port is removed.

This facility is primarily intended for use by database servers behind proxies which are unaware of their externally visible network address.