default=False, help="Publish on official or test database") (options, args) = parser.parse_args() # If there are no options selected exit. if options.sql is None and options.alias is None: parser.print_help() sys.exit(1) # Allow no less than one argument if len(args) < 1: parser.print_help() sys.exit(1) cmgdbApi = CmgdbApi(options.development) cmgdbApi.connect() description = cmgdbApi.describe() parser.usage = """ Table Structure: """ + description + """ The database server being used is Oracle 11g, so a good idea would be to become farmiliar with the Oracle 11g query semantics. Here are some example queries explained: If you want to get a list of tags that were used by cmgtools on the 7th March 2012, - You will have to first make sure that you use the distinct() method to prevent repetitions - Once you have specified the information you want, you will then need to perform a join with the tags_in_sets table on tag_id - From the product of this join you then want to join with the dataset_details table, this time on tagset_id - You then specify the WHERE clause as where file_owner = 'cmgtools and the date... - To give the results of the entire day, you must do two things, -- First, use the trunc() method to truncate the timestamp to the desired length
import sys import pprint import os import re import operator import subprocess import re from CMGTools.Production.cmgdbApi import CmgdbApi from CMGTools.RootTools.utils.getFiles import getFiles db = CmgdbApi() db.connect() def findFirstAncestor(dataset_id, info): cols, rows = db.sql( "select parent_dataset_id, path_name, primary_dataset_entries, number_total_jobs, task_id, dataset_entries FROM dataset_details where dataset_id={dataset_id}" .format(dataset_id=dataset_id)) if len(rows) == 0: print 'cannot find dataset with id', dataset_id elif len(rows) > 1: assert (False) else: parent_id = rows[0][0] groups = [ 'tauMu_fullsel_tree_CMG', 'tauMu_fullsel_tree', 'tauEle_fullsel_tree_CMG', 'tauEle_fullsel_tree', 'diTau_fullsel_tree_CMG', 'diTau_fullsel_tree', 'cmgTuple', 'htt_fullsel_tree_CMG', 'htt_fullsel_tree', 'PFAOD' ]
#!/bin/env python from CMGTools.Production.cmgdbApi import CmgdbApi import CMGTools.Production.eostools as eos import pprint db = CmgdbApi() db.connect() cols, rows = db.sql("select path_name, file_owner, number_files_bad, number_files_good from dataset_details where path_name like '%V5_4_0'") # pprint.pprint(rows) dead = [] good = [] nscanned = 0 for row in rows: # print row path = row[0] owner = row[1] nFiles = None if row[2] is not None and row[3] is not None: nFiles = row[2]+row[3] print path, nFiles dir = None if owner == 'cmgtools_group': dir = '/eos/cms/store/cmst3/group/cmgtools/CMG'+path elif owner == 'cmgtools': dir = '/eos/cms/store/cmst3/user/cmgtools/CMG'+path
help="Publish on official or test database" ) (options, args) = parser.parse_args() # If there are no options selected exit. if options.sql is None and options.alias is None: parser.print_help() sys.exit(1) # Allow no less than one argument if len(args)<1: parser.print_help() sys.exit(1) cmgdbApi = CmgdbApi(options.development) cmgdbApi.connect() description = cmgdbApi.describe() parser.usage = """ Table Structure: """+description+""" The database server being used is Oracle 11g, so a good idea would be to become farmiliar with the Oracle 11g query semantics. Here are some example queries explained: If you want to get a list of tags that were used by cmgtools on the 7th March 2012, - You will have to first make sure that you use the distinct() method to prevent repetitions - Once you have specified the information you want, you will then need to perform a join with the tags_in_sets table on tag_id - From the product of this join you then want to join with the dataset_details table, this time on tagset_id - You then specify the WHERE clause as where file_owner = 'cmgtools and the date... - To give the results of the entire day, you must do two things, -- First, use the trunc() method to truncate the timestamp to the desired length