AccountingDB
Frontend to MySQL DB AccountingDB
- class DIRAC.AccountingSystem.DB.AccountingDB.AccountingDB(name='Accounting/AccountingDB', readOnly=False, parentLogger=None)
Bases:
DB
- __init__(name='Accounting/AccountingDB', readOnly=False, parentLogger=None)
c’tor
- Parameters:
self – self reference
- autoCompactDB()
- buildCondition(condDict=None, older=None, newer=None, timeStamp=None, orderAttribute=None, limit=False, greater=None, smaller=None, offset=None, useLikeQuery=False)
Build SQL condition statement from provided condDict and other extra check on a specified time stamp. The conditions dictionary specifies for each attribute one or a List of possible values greater and smaller are dictionaries in which the keys are the names of the fields, that are requested to be >= or < than the corresponding value. For compatibility with current usage it uses Exceptions to exit in case of invalid arguments For performing LIKE queries use the parameter useLikeQuery=True
- calculateBucketLengthForTime(typeName, now, when)
Get the expected bucket time for a moment in time
- calculateBuckets(typeName, startTime, endTime, nowEpoch=False)
Magic function for calculating buckets between two times and the proportional part for each bucket
- changeBucketsLength(typeName, bucketsLength)
- compactBuckets(typeFilter=False)
Compact buckets for all defined types
- countEntries(table, condDict, older=None, newer=None, timeStamp=None, connection=False, greater=None, smaller=None)
Count the number of entries wit the given conditions
- deleteEntries(tableName, condDict=None, limit=False, conn=None, older=None, newer=None, timeStamp=None, orderAttribute=None, greater=None, smaller=None)
Delete rows from “tableName” with N records can match the condition if limit is not False, the given limit is set String type values will be appropriately escaped, they can be single values or lists of values.
- deleteRecord(typeName, startTime, endTime, valuesList)
Delete an entry
- deleteType(**kwargs)
Deletes a type
- executeStoredProcedure(packageName, parameters, outputIds, *, conn=None)
- executeStoredProcedureWithCursor(packageName, parameters, *, conn=None)
- getBucketsDef(typeName)
- getCSOption(optionName, defaultValue=None)
- getCounters(table, attrList, condDict, older=None, newer=None, timeStamp=None, connection=False, greater=None, smaller=None)
Count the number of records on each distinct combination of AttrList, selected with condition defined by condDict and time stamps
- getDistinctAttributeValues(table, attribute, condDict=None, older=None, newer=None, timeStamp=None, connection=False, greater=None, smaller=None)
Get distinct values of a table attribute under specified conditions
- getFields(tableName, outFields=None, condDict=None, limit=False, conn=None, older=None, newer=None, timeStamp=None, orderAttribute=None, greater=None, smaller=None, useLikeQuery=False)
Select “outFields” from “tableName” with condDict N records can match the condition return S_OK(tuple(Field, Value)) if outFields is None all fields in “tableName” are returned if limit is not False, the given limit is set inValues are properly escaped using the _escape_string method, they can be single values or lists of values. if useLikeQuery=True, then conDict can return matched rows if “%” is defined inside conDict.
- getKeyValues(typeName, condDict, connObj=False)
Get all values for a given key field in a type
- getRegisteredTypes()
Get list of registered types
- getWaitingRecordsLifeTime()
Get the time records can live in the IN tables without no retry
- insertFields(tableName, inFields=None, inValues=None, conn=None, inDict=None)
Insert a new row in “tableName” assigning the values “inValues” to the fields “inFields”. String type values will be appropriately escaped.
- insertRecordBundleThroughQueue(recordsToQueue)
- insertRecordDirectly(typeName, startTime, endTime, valuesList)
Add an entry to the type contents
- insertRecordThroughQueue(typeName, startTime, endTime, valuesList)
Insert a record in the intable to be really insterted afterwards
- loadPendingRecords()
Load all records pending to insertion and generate threaded jobs
- markAllPendingRecordsAsNotTaken()
Mark all records to be processed as not taken NOTE: ONLY EXECUTE THIS AT THE BEGINNING OF THE DATASTORE SERVICE!
- regenerateBuckets(typeName)
- registerType(**kwargs)
Register a new type
- retrieveBucketedData(typeName, startTime, endTime, selectFields, condDict, groupFields, orderFields, connObj=False)
Get data from the DB
- Parameters:
typeName (- typeName ->)
int (- startTime & endTime ->) – epoch objects. Do I need to explain the meaning?
selectFields (-) – list containing a string and a list of fields: [“SUM(%s), %s/%s”, [“field1name”, “field2name”, “field3name”]]
query (- condDict -> conditions for the) – key -> name of the field value -> list of possible values
by (- orderFields -> list of fields to order) – ( “%s, %s, %s”, ( “field1name”, “field2name”, “field3name” ) )
by – ( “%s, %s, %s”, ( “field1name”, “field2name”, “field3name” ) )
- retrieveRawRecords(typeName, startTime, endTime, condDict, orderFields, connObj=False)
Get RAW data from the DB
- transactionCommit()
- transactionRollback()
- transactionStart()
- updateFields(tableName, updateFields=None, updateValues=None, condDict=None, limit=False, conn=None, updateDict=None, older=None, newer=None, timeStamp=None, orderAttribute=None, greater=None, smaller=None)
Update “updateFields” from “tableName” with “updateValues”. updateDict alternative way to provide the updateFields and updateValues N records can match the condition return S_OK( number of updated rows ) if limit is not False, the given limit is set String type values will be appropriately escaped.