IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 25, 2013, 9:01:58 PM (13 years ago)
Author:
eugene
Message:

add method to insert StackDetectionCalib values using select into + load from file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/stackbatch.py

    r35056 r35057  
    22
    33import os.path
     4import glob
    45import sys
    56
     
    717718    calling the load data infile '/tmp/name' into table;
    718719    '''
    719     def populateStackDetectionCalib(self):
     720    def populateStackDetectionCalibInsertUpdate(self):
    720721        self.logger.infoPair("Processing table", "StackDetectionCalib")
    721722        tableName = "StackDetectionCalib"
     
    757758        self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.config.dataRelease))
    758759       
    759    
    760 
     760    def populateStackDetectionCalib(self):
     761
     762        tableName = "StackDetectionCalib"
     763        self.logger.infoPair("Processing table", tableName)
     764
     765        imageID = self.scratchDb.getImageIDFromExternID(self.header['IMAGEID'])
     766        self.logger.infoPair("obtained","imageID")
     767
     768        dumpFile = "/tmp/datadump/genetest.xx.dat"
     769        files = glob.glob(dumpFile)
     770        if len(files) > 0:
     771            os.unlink(dumpFile)
     772
     773        # insert all detections into table
     774        sql = "SELECT \
     775          a.objID,    \
     776          a.stackDetectID, \
     777          a.ippObjID,      \
     778          a.ippDetectID,   \
     779          a.filterID,      \
     780          a.surveyID,      \
     781          b.ra,            \
     782          b.dec_,          \
     783          b.raErr,         \
     784          b.decErr,        \
     785          b.zp,            \
     786          b.zpErr,         \
     787          b.expTime,       \
     788          b.airMass,       \
     789          a.dataRelease    \
     790         FROM              \
     791           StackDetection as a \
     792         JOIN " + self.scratchDb.dvoDetectionTable + " as b \
     793         ON (a.stackDetectID = b.detectID) where b.imageID = " + str(imageID) + \
     794         " INTO OUTFILE '" + dumpFile + "'"
     795        print "sql: ", sql
     796        self.scratchDb.execute(sql)
     797
     798        sql = "LOAD DATA INFILE '" + dumpFile + "' INTO TABLE " + tableName
     799        print "sql: ", sql
     800        self.scratchDb.execute(sql)
     801        self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.config.dataRelease))
    761802
    762803    '''
Note: See TracChangeset for help on using the changeset viewer.