def call_procedure(self, procedure, read_only=False, *args, **kwagrs): args = [quote_string(arg) for arg in args] q = 'CALL %s(%s)' % (procedure, ','.join(args)) y = kwagrs.get('y', None) if y: q += ' YIELD %s' % ','.join(y) return self.query(q, read_only=read_only)
def build_params_header(self, params): if not isinstance(params, dict): raise TypeError("'params' must be a dict") # Header starts with "CYPHER" params_header = "CYPHER " for key, value in params.items(): # If value is string add quotation marks. if isinstance(value, str): value = quote_string(value) # Value is None, replace with "null" string. elif value is None: value = "null" params_header += str(key) + "=" + str(value) + " " return params_header
def test_quote_string(self): self.assertEqual(util.quote_string(10), 10) self.assertEqual(util.quote_string("abc"), '"abc"') self.assertEqual(util.quote_string(""), '""') self.assertEqual(util.quote_string('a"a'), '"a\\"a"')