Package wsatools :: Module FitsToDb :: Class AttributeUpdater
[hide private]

Class AttributeUpdater

source code


Updates all of the values in a set of database columns from the original FITS header keyword values using the prescription described in the table schema. The set of database columns may be manually supplied and to these any new columns, defined in the schema yet not present in the database, will be automatically included and created in the database. If there no new columns in the schema and no columns are manually supplied then no updates are performed.

This class is used by FitsReader which, when retrieving the list of FITS files to be read, invokes _prepare() to determine the list of attributes to be updated and uses DbUpdater to prepare the file list. FitsReader then calls updateDb() to update each record.

Nested Classes [hide private]
    Nested Errors and Exceptions

Inherited from DbConnect.CuSession.CuSession: CuError

Instance Methods [hide private]
 
_onRun(self)
Run the database updater.
source code
 
_prepare(self)
Determines the list of attributes to be updated and fills the list of records that need to be updated.
source code
list(schema.Attribute)
_prepTableAttrList(self, tableName, attrList)
Reduce the list of attributes for a given table to just those that need to be updated.
source code
 
updateDb(self, mfid, fitsFile=None, filePathName=None)
Update entries for previously selected list of attributes in the database record for this multiframe ID.
source code

Inherited from DbUpdater: getErrorLog, getFileList

Inherited from DbUpdater (private): _getRecordsList, _stripServerName

Inherited from DbConnect.CuSession.CuSession: __del__, __init__, logBrokenFile, run

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]

Inherited from DbConnect.CuSession.CuSession: logException

Class Variables [hide private]
  _isPersistent = True
Should this curation task try to re-open broken database connections?
  comment = 'Updating tables with new schema attributes'
Descriptive comment as to why curation task is being performed.
  doStacksOnly = False
Only update attributes from stack files?
  reqAttrs = None
List of named attributes that already exist in the db to update.
  schemaFileName = 'WSA_MultiframeSchema.sql'
Name of the .sql file defining the schema to update.
  tableList = ['Multiframe', 'MultiframeDetector']
List of tables within the schema to be updated.
  _attrUpdateList = []
List of attribute lists for every table to update.

Inherited from DbConnect.CuSession.CuSession: archive, cuEventID, cuNum, curator, eTypes, isDayStampedLog, onlyNonSurveys, onlySurveys, programme, programmeID, resultsFilePathName, shareFileID, sysc

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

_onRun(self)

source code 

Run the database updater. Wrapper to catch table not found in schema errors, which are most likely to be caused by user input error.

Overrides: DbConnect.CuSession.CuSession._onRun

_prepare(self)

source code 

Determines the list of attributes to be updated and fills the list of records that need to be updated.

Overrides: DbUpdater._prepare

_prepTableAttrList(self, tableName, attrList)

source code 

Reduce the list of attributes for a given table to just those that need to be updated. Compares the schema described by the .sql file with that in the current database to see if there are any new attributes. If so, new columns are added to the database for these attributes with default values.

Parameters:
  • tableName (str) - Database table to update.
  • attrList (list(schema.Attribute)) - List of all attributes in this table.
Returns: list(schema.Attribute)
The list of attributes that need to be updated for this table.

updateDb(self, mfid, fitsFile=None, filePathName=None)

source code 

Update entries for previously selected list of attributes in the database record for this multiframe ID.

Parameters:
  • mfid - MultiframeID of database record to update. @type mfid int
  • fitsFile - Open FITS file containing the data for this mfid. @type fitsFile pyfits.HDUList
  • filePathName (str) - Full path to the FITS file.
Overrides: DbUpdater.updateDb