# import RCDB from rcdb.provider import RCDBProvider # connect to DB db = RCDBProvider("mysql://[email protected]/rcdb") # select values with query table = db.select_values(['cdc_gas_pressure'], run_min=41512, run_max=41540) for row in table: (run_number, cdc_gas_pressure) = tuple(row) print("{} {}".format(run_number, cdc_gas_pressure))
# E X A M P L E 1 # 3 Lines to get values!!! from rcdb.provider import RCDBProvider db = RCDBProvider("mysql://[email protected]/rcdb") table = db.select_values(['polarization_angle', 'polarization_direction'], runs=[30641, 30653]) # P R I N T O U T 1 # Print results print(" run_number, polarization_angle, polarization_direction") for row in table: print (row[0], row[1], row[2]) # E X A M P L E 2 # select values description # Default value | Descrition #---------------+------------------------------------ table = db. select_values(val_names=['event_count', 'beam_current'], # [] | List of conditions names to select, empty by default search_str="@is_production and event_count>1000", # "" | Search pattern. run_min=30200, # 0 | minimum run to search/select run_max=30301, # sys.maxsize | maximum run to search/select sort_desc=True, # False | if True result runs will by sorted descendant by run_number, ascendant if False insert_run_number=True, # True | If True the first column of the result will be a run number runs=None) # None | a list of runs to search from. In this case run_min and run_max are not used # Some more remarks # # 1. val_names. If val_names is left empty, run numbers will be selected (assuming that insert_run_number=True by default)
# E X A M P L E 1 # 3 Lines to get values!!! from rcdb.provider import RCDBProvider db = RCDBProvider("mysql://[email protected]/rcdb") table = db.select_values(['polarization_angle', 'polarization_direction'], runs=[30641, 30653]) # # # P R I N T O U T 1 # # Print results # print(" run_number, polarization_angle, polarization_direction") for row in table: print row[0], row[1], row[2] # # # # E X A M P L E 2 # # select values description # # # Default value | Descrition # #---------------+------------------------------------ # table = db. select_values(val_names=['event_count', 'beam_current'], # [] | List of conditions names to select, empty by default # search_str="@is_production and event_count>1000", # "" | Search pattern. # run_min=30200, # 0 | minimum run to search/select # run_max=30301, # sys.maxsize | maximum run to search/select # sort_desc=True, # False | if True result runs will by sorted descendant by run_number, ascendant if False # insert_run_number=True, # True | If True the first column of the result will be a run number # runs=None) # None | a list of runs to search from. In this case run_min and run_max are not used # # Some more remarks # # # # 1. val_names. If val_names is left empty, run numbers will be selected (assuming that insert_run_number=True by default)