CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
framework_test.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import pprint
4 import datetime
5 
6 if __name__ == "__main__":
7  # this class should extend a framework base class that
8  # provides default implementations of important methods
9  import sys
10  from CondCore.Utilities.CondDBFW import querying_framework_api
11  import CondCore.Utilities.CondDBFW.data_sources as data_sources, CondCore.Utilities.CondDBFW.data_formats as format
12  from CondCore.Utilities.CondDBFW.querying import connect
13 
14  class query_script():
15 
16  def script(self, connection):
17  gt = connection.global_tag(name="74X_dataRun1_HLT_frozen_v2")
18  valid_iovs = gt.iovs(valid=True, amount=100)
19  json_structure = data_sources.json_dict()
20  json_structure.add_key(gt.snapshot_time, "snapshot_time")
21  json_structure.add_key(valid_iovs, "valid_iovs")
22  return json_structure
23 
24  secrets_file = "/afs/cern.ch/cms/DB/conddb/.cms_cond/netrc"
25  secrets_file_1 = "netrc_test"
26 
27  connection_data = {"db_alias" : "orapro", "schema" : "cms_conditions", "host" : "oracle", "secrets" : secrets_file}
28  qf = querying_framework_api(connection_data)
29  data = qf.run_script(query_script())
30 
31  data.get("valid_iovs").as_table(fit=["tag_name", "payload_hash", "insertion_time"], col_width=35)
32 
33  pprint.pprint(data.data())