QueryBuilder

class pysnow.query_builder.QueryBuilder[source]

Query builder - for constructing advanced ServiceNow queries

field(field)[source]

Sets the field to operate on

Parameters:field – field (str) to operate on
order_descending()[source]

Sets ordering of field descending

order_ascending()[source]

Sets ordering of field ascending

starts_with(starts_with)[source]

Adds new STARTSWITH condition

Parameters:starts_with – Match field starting with the provided value
ends_with(ends_with)[source]

Adds new ENDSWITH condition

Parameters:ends_with – Match field ending with the provided value
contains(contains)[source]

Adds new LIKE condition

Parameters:contains – Match field containing the provided value
not_contains(not_contains)[source]

Adds new NOTLIKE condition

Parameters:not_contains – Match field not containing the provided value
is_empty()[source]

Adds new ISEMPTY condition

equals(data)[source]

Adds new IN or = condition depending on if a list or string was provided

Parameters:

data – string or list of values

Raise:
  • QueryTypeError: if data is of an unexpected type
not_equals(data)[source]

Adds new NOT IN or = condition depending on if a list or string was provided

Parameters:

data – string or list of values

Raise:
  • QueryTypeError: if data is of an unexpected type
greater_than(greater_than)[source]

Adds new > condition

Parameters:

greater_than – str or datetime compatible object

Raise:
less_than(less_than)[source]

Adds new < condition

Parameters:

less_than – str or datetime compatible object

Raise:
  • QueryTypeError: if less_than is of an unexpected type
between(start, end)[source]

Adds new BETWEEN condition

Parameters:
  • start – int or datetime compatible object
  • end – int or datetime compatible object
Raise:
  • QueryTypeError: if start or end arguments is of an invalid type
AND()[source]

Adds an and-operator

OR()[source]

Adds an or-operator

NQ()[source]

Adds a NQ-operator (new query)