simdb.query module¶
- class simdb.query.QueryType(value)[source]¶
Bases:
EnumSimDB query comparator options.
- AGE = 11¶
- AGT = 10¶
- ALE = 13¶
- ALT = 12¶
- EQ = 2¶
- EXIST = 14¶
- GE = 7¶
- GT = 6¶
- IN = 4¶
- LE = 9¶
- LT = 8¶
- NE = 3¶
- NI = 5¶
- NONE = 1¶
- simdb.query.parse_query_arg(value: str) Tuple[str, QueryType][source]¶
Parse the second half of a SimDB query argument and return the comparator type and value to be compared.
- The strings being parsed will be of the form:
value comparator:value
If no comparator is given then QueryType.EQ is returned as a default.
- Parameters:
value – The query string to parse.
- Returns:
The extracted value and comparator.
- simdb.query.query_compare(query_type: QueryType, name: str, value: Any, compare: str) bool[source]¶
Perform a comparison between the compare string and the given value based on the comparison type given in query_type.
- Parameters:
query_type – The type of comparison being performed.
name – The name of the field being compared. Used when reporting an error.
value – The value being compared. This can be a string, a number or a numpy array.
compare – The string representation of the value being compared against.
- Returns:
The result of the comparison.
- Raises:
ValueError – If the comparison could not be performed.