-
Notifications
You must be signed in to change notification settings - Fork 7
Query syntax
Queries allow to select runs using simple python logic 'if syntax'. Condition names and aliases are used variables. Queries are used in web GUI, python API and CLI interfaces. Here are examples:
Here is example of query to get production runs beam current around 100 uA and 'BCAL' in run_config ( here 'BCAL' is a detector / subsystem in HallD and run_config is a name of a configuration file):
General/web site query:
@is_production and 120 > beam_current > 80 and 'BCAL' in run_config
Queries syntax are the same across API-s (which supports queries at all)
python:
runs = db.select_runs("@is_production and 120 > beam_current > 80 and 'BCAL' in run_config")
CLI:
>>rcdb sel "@is_production and 120 > beam_current > 80 and 'BCAL' in run_config"
Queries use python 'if' syntax. The full python documentation is here.
Concise version is:
-
<
,<=
,==
,!=
,=>
,>
to compare values (same as in C++) -
or
,and
,not
for logic operators (||, &&, ! in C++) -
in
operator to check for arrays, (arrays are in square braces[]
):5 in radiator_id radiator_id in [5,6,12]
-
strings must be in
'
- single braces.==
compares two strings,in
operator works for substrings:run_config == 'FCAL_BCAL_PS_m7.conf' 'hd_all' in run_type
One may notice @is_production
in the query example above. @
means 'alias' - predefined set of conditions. For example for HallD @is_production
alias is given as:
run_type in ['hd_all.tsg', 'hd_all.tsg_ps', 'hd_all.bcal_fcal_st.tsg'] and
beam_current > 2 and
event_count > 500000 and
solenoid_current > 100 and
collimator_diameter != 'Blocking'
Getting started & basic usage:
- Installation
- Select values tutorial (python)
- Query syntax
- Add data (python)
- CLI Basics
RCDB Explained:
- Connection
- DB and APIs structure
- SQL examples
- Creating condition types
- Adding condition values
- Saving files
- SQLAlchemy
- Logging
- Performance
Command line tools:
DAQ: