@ensure_connection<EOL><INDENT>def cypher_query(self, query, params=None, handle_unique=True, retry_on_session_expire=False, resolve_objects=False):<DEDENT>
if self._pid != os.getpid():<EOL><INDENT>self.set_connection(self.url)<EOL><DEDENT>if self._active_transaction:<EOL><INDENT>session = self._active_transaction<EOL><DEDENT>else:<EOL><INDENT>session = self.driver.session()<EOL><DEDENT>try:<EOL><INDENT>start = time.time()<EOL>response = session.run(query, params)<EOL>results, meta = [list(r.values()) for r in response], response.keys()<EOL>end = time.time()<EOL>if resolve_objects:<EOL><INDENT>results = self._object_resolution(results)<EOL><DEDENT><DEDENT>except CypherError as ce:<EOL><INDENT>if ce.code == u'<STR_LIT>':<EOL><INDENT>if '<STR_LIT>' in ce.message and handle_unique:<EOL><INDENT>raise UniqueProperty(ce.message)<EOL><DEDENT>raise ConstraintValidationFailed(ce.message)<EOL><DEDENT>else:<EOL><INDENT>exc_info = sys.exc_info()<EOL>if sys.version_info >= (<NUM_LIT:3>, <NUM_LIT:0>):<EOL><INDENT>raise exc_info[<NUM_LIT:1>].with_traceback(exc_info[<NUM_LIT:2>])<EOL><DEDENT>else:<EOL><INDENT>raise exc_info[<NUM_LIT:1>]<EOL><DEDENT><DEDENT><DEDENT>except SessionError:<EOL><INDENT>if retry_on_session_expire:<EOL><INDENT>self.set_connection(self.url)<EOL>return self.cypher_query(query=query,<EOL>params=params,<EOL>handle_unique=handle_unique,<EOL>retry_on_session_expire=False)<EOL><DEDENT>raise<EOL><DEDENT>if os.environ.get('<STR_LIT>', False):<EOL><INDENT>logger.debug("<STR_LIT>" + query + "<STR_LIT>" + repr(params) + "<STR_LIT>".format(end - start))<EOL><DEDENT>return results, meta<EOL>
Runs a query on the database and returns a list of results and their headers.

:param query: A CYPHER query
:type: str
:param params: Dictionary of parameters
:type: dict
:param handle_unique: Whether or not to raise UniqueProperty exception on Cypher's ConstraintValidation errors
:type: bool
:param retry_on_session_expire: Whether or not to attempt the same query again if the transaction has expired
:type: bool        
:param resolve_objects: Whether to attempt to resolve the returned nodes to data model objects automatically
:type: bool