slims.criteria module¶
-
class
slims.criteria.
Expression
(criterion: dict)¶ Bases:
slims.criteria.Criterion
A simple expression like ‘cntn_id’ equals ‘test’
-
to_dict
() → dict¶ Serializes criterion to dictionary
-
-
class
slims.criteria.
Junction
(operator: slims.criteria._JunctionType)¶ Bases:
slims.criteria.Criterion
A combination of multiple criteria
-
add
(member: slims.criteria.Criterion) → slims.criteria.Junction¶ Adds a member to this junction
-
to_dict
() → dict¶ Serializes criterion to dictionary
-
-
slims.criteria.
between_inclusive
(field: str, start: Any, end: Any) → slims.criteria.Expression¶ Applies a “between” constraint to the specified field
Parameters: - field (string) – the field to match
- start (any) – the value to start with (inclusive)
- start – the value to end with (inclusive)
Returns: A between criterion
Examples
>>> slims.fetch("Content", between_inclusive("cntn_barCode", "00001", "00010"))
Will fetch all the content records that have a barcode between 00001 and 00010
-
slims.criteria.
conjunction
() → slims.criteria.Junction¶ Combines multiple criteria in a conjunctive way (and)
Returns: A conjunction Examples
>>> slims.fetch("Content", conjunction() .add(start_with("cntn_id", "DNA")) .add(greater_than("cntn_quantity", 5)))
Will fetch all the content records for which their id starts with “DNA” and their quantity is bigger than 5.
-
slims.criteria.
contains
(field: str, value: Any) → slims.criteria.Expression¶ Applies a “contains” constraint to the specified field
Parameters: - field (string) – the field to match
- value (any) – the value to contain
Returns: A contains criterion
Examples
>>> slims.fetch("Content", contains("cntn_id", "test"))
Will fetch all the content records that have an id that contains “test”
-
slims.criteria.
disjunction
() → slims.criteria.Junction¶ Combines multiple criteria in a disjunctive way (or)
Returns: A disjunction Examples
>>> slims.fetch("Content", disjunction() .add(start_with("cntn_id", "DNA")) .add(greater_than("cntn_quantity", 5)))
Will fetch all the content records for which their id starts with “DNA” or their quantity is bigger than 5.
-
slims.criteria.
ends_with
(field: str, value: Any) → slims.criteria.Expression¶ Applies an “ends with” constraint to the specified field
Parameters: - field (string) – the field to match
- value (any) – the value to end with
Returns: An ends with criterion
Examples
>>> slims.fetch("Content", ends_with("cntn_id", "001"))
Will fetch all the content records that have an id that ends with “001”
-
slims.criteria.
equals
(field: str, value: Any) → slims.criteria.Expression¶ Applies an “equals” constraint to the specified field
This is case-sensitive depending on the used database.
Parameters: - field (string) – the field to match
- value (any) – the value to match
Returns: An equals criterion
Examples
>>> slims.fetch("Content", equals("cntn_id", "dna0001"))
This will fetch all the content records that have “dna0001” as their id
-
slims.criteria.
equals_ignore_case
(field: str, value: Any) → slims.criteria.Expression¶ Applies an “equals” constraint to the specified field
This is always case-insensitive
Parameters: - field (string) – the field to match
- value (any) – the value to match
Returns: An equals criterion
Examples
>>> slims.fetch("Content", equals_ignore_case("cntn_id", "dna0001"))
Will fetch all the content records that have “dna0001” as their id
-
slims.criteria.
greater_than
(field: str, value: Any) → slims.criteria.Expression¶ Applies an “greater than” constraint to the specified field
Parameters: - field (string) – the field to match
- value (any) – the value to match
Returns: A greater than criterion
Examples
>>> slims.fetch("Content", greater_than("cntn_quantity", "5"))
Will fetch all the content records that have a quantity greater than 5
-
slims.criteria.
greater_than_or_equal
(field: str, value: Any) → slims.criteria.Expression¶ Applies an “greater than or equal” constraint to the specified field
Parameters: - field (string) – the field to match
- value (any) – the value to match
Returns: A less than or equal criterion
Examples
>>> slims.fetch("Content", greater_than_or_equal("cntn_quantity", "5"))
Will fetch all the content records that have a quantity greater than or equal to 5
-
slims.criteria.
is_na
(field: str) → slims.criteria.Expression¶ Applies a “is not applicable” constraint to the specified field (this is an option on custom fields
Parameters: field (string) – the field that should not be applicable Returns: A not applicable criterion Examples
>>> slims.fetch("Content", is_na("cntn_cf_numberOfSigarettes"))
Will fetch all the content records for which the number of sigarrettes is not applible (for example for non smokers)
-
slims.criteria.
is_not
(criterion: slims.criteria.Criterion) → slims.criteria.Junction¶ Inverts a criterion
Parameters: criterion (criterion) – The criterion to invert Returns: A criterion Examples
>>> slims.fetch("Content", is_not(start_with("cntn_id", "DNA")))
Will fetch all the content records for which their id does not starts with “DNA”
-
slims.criteria.
is_not_null
(field: str) → slims.criteria.Expression¶ Applies an “is not null” constraint to the specified field
Parameters: field (string) – the field that shouldn’t be null Returns: A not null criterion Examples
>>> slims.fetch("Content", is_not_null("cntn_fk_location"))
Will fetch all the content records that are in a location
-
slims.criteria.
is_not_one_of
(field: str, value: list) → slims.criteria.Expression¶ Applies an “is not one of” constraint to the specified field
Parameters: - field (string) –
- value (list) –
Examples
>>> slims.fetch("Content", is_not_one_of("cntn_barCode", ["0001", "0002", "0004"]))
Will fetch all the content records that have a barcode that is not 0001, 0002 or 0004.
-
slims.criteria.
is_null
(field: str) → slims.criteria.Expression¶ Applies an “is null” constraint to the specified field
Parameters: field (string) – the field that should be null Returns: An is null criterion Examples
>>> slims.fetch("Content", is_null("cntn_fk_location"))
Will fetch all the content records that are not in a location
-
slims.criteria.
is_one_of
(field: str, value: list) → slims.criteria.Expression¶ Applies an “is one of” constraint to the specified field
Parameters: - field (string) –
- value (list) –
Examples
>>> slims.fetch("Content", is_one_of("cntn_barCode", ["0001", "0002", "0004"]))
Will fetch all the content records that have a barcode that is either 0001, 0002 or 0004.
-
slims.criteria.
less_than
(field: str, value: Any) → slims.criteria.Expression¶ Applies an “less than” constraint to the specified field
Parameters: - field (string) – the field to match
- value (any) – the value to match
Returns: A less than criterion
Examples
>>> slims.fetch("Content", less_than("cntn_quantity", "5"))
Will fetch all the content records that have a quantity smaller than 5
-
slims.criteria.
less_than_or_equal
(field: str, value: Any) → slims.criteria.Expression¶ Applies an “less than or equal” constraint to the specified field
Parameters: - field (string) – the field to match
- value (any) – the value to match
Returns: A less than or equal criterion
Examples
>>> slims.fetch("Content", less_than_or_equal("cntn_quantity", "5"))
Will fetch all the content records that have a quantity less than or equal to 5
-
slims.criteria.
not_equals
(field: str, value: Any) → slims.criteria.Expression¶ Applies an “not equals” constraint to the specified field
Parameters: - field (string) – the field to match
- value (any) – the value not to match
Returns: A not equals criterion
Examples
>>> slims.fetch("Content", not_equals("cntn_id", "dna0001"))
Will fetch all the content records that do not have “dna0001” as their id
-
slims.criteria.
starts_with
(field: str, value: Any) → slims.criteria.Expression¶ Applies a “starts with” constraint to the specified field
Parameters: - field (string) – the field to match
- value (any) – the value to start with
Returns: A starts with criterion
Examples
>>> slims.fetch("Content", start_with("cntn_id", "dna"))
Will fetch all the content records that have an id that starts with “dna”