Пример #1
0
 def getFullCommand(self, valuePool):
     parts=[] 
     for thisArg in self.args:
         value = thisArg.value
         
         for thisPlaceHolder in thisArg.placeholders:
             value = value.replace("%s",valuePool[thisPlaceHolder],1)
         
         parts.append(value)
     command = cs.delimitedStringList(parts, " ")
     return(command)
Пример #2
0
        def __init__(self, configRoot, configName):
            self.configName = configName
            self.connectionFile = os.path.join(configRoot, "connections", configName + ".xml")
            xmlDoc = etree.parse(self.connectionFile).getroot()
            credentialsDocument = xmlDoc.attrib
            self.credentials = {}

            params = []
            for thisCredential in  credentialsDocument.items():
                if thisCredential[0] not in("vendor", "label", "version"):
                    self.credentials[thisCredential[0]] = thisCredential[1]
                    param = "%s=%s" % (thisCredential[0], thisCredential[1])
                    params.append(param)

            self.connectString = cs.delimitedStringList(params, " ")
Пример #3
0
    def processImportSyncDeletes(
        self, loopConnection, dataConnection, dataCursor, settings, taskId, processLimit, specification, args
    ):

        minTaskId = args["minTaskId"]
        maxTaskId = args["maxTaskId"]

        successCount = 0
        exceptionCount = 0
        errorCount = 0
        warningCount = 0
        noticeCount = 0
        ignoredCount = 0

        self.queue.startTask(taskId, True)
        if minTaskId is not None and maxTaskId is not None:

            # Scanning
            for thisRecord in specification.records:
                if thisRecord.table == args["table"]:

                    if minTaskId == maxTaskId:
                        sql = "select count(*) from import.%s" % (thisRecord.table)
                        sql = sql + " where last_affirmed_task_id != %s"
                        settings.appLogger.debug("|   staleSql:{0}".format(sql))
                        dataCursor.execute(sql, (minTaskId,))
                    else:
                        sql = "select count(*) from import.%s" % (thisRecord.table)
                        sql = sql + " where last_affirmed_task_id not (between %s and %s)"
                        settings.appLogger.debug("|   staleSql:{0}".format(sql))
                        dataCursor.execute(sql, (minTaskId, maxTaskId))

                    staleCount = int(dataCursor.fetchone()[0])

                    self.queue.setScanResults(taskId, staleCount)
                    settings.appLogger.debug("|   staleCount: {0}".format(staleCount))

                    params = []
                    for i in range(0, len(thisRecord.primaryKeyColumns) + 1):
                        params.append("%s")
                    dml = "select * from import.%s_delete(%s)" % (thisRecord.table, cs.delimitedStringList(params, ","))

                    if minTaskId == maxTaskId:
                        sql = "select %s from import.%s" % (
                            cs.delimitedStringList(thisRecord.primaryKeyColumns, ","),
                            thisRecord.table,
                        )
                        sql = sql + " where last_affirmed_task_id != %s"
                        settings.appLogger.debug("|   dataSQL: {0}".format(sql % (minTaskId)))
                        dataCursor.execute(sql, (minTaskId,))
                    else:
                        sql = "select %s from import.%s" % (
                            cs.delimitedStringList(thisRecord.primaryKeyColumns, ","),
                            thisRecord.table,
                        )
                        sql = sql + " where last_affirmed_task_id not (between %s and %s)"
                        settings.appLogger.debug("|   dataSQL:{0}".format(sql % (minTaskId, maxTaskId)))
                        dataCursor.execute(sql, (minTaskId, maxTaskId))
                    settings.appLogger.debug("|   dml: {0}".format(dml))
                    results = dataCursor.fetchall()
                    deletedRowCount = 0
                    for data in results:
                        deleteParams = []
                        deleteParams.append(taskId)
                        i = 0
                        for thisPkColumn in thisRecord.primaryKeyColumns:
                            deleteParams.append(data[i])
                            i = i + 1

                        if deletedRowCount < 10:
                            settings.appLogger.debug("|   {0}".format(deleteParams))

                        dataCursor.execute(dml, tuple(deleteParams))
                        deletedRowCount += 1

                        messages = dataCursor.fetchall()
                        for thisMessage in messages:
                            msgLevel = thisMessage[0]
                            msgCode = thisMessage[1]
                            msgTitle = thisMessage[2]
                            msgAffectedColumns = thisMessage[3]
                            msgAffectedRowCount = thisMessage[4]
                            msgContent = thisMessage[5]
                            self.queue.addTaskMessage(
                                taskId,
                                thisRecord.table,
                                0,
                                msgLevel,
                                msgCode,
                                msgTitle,
                                msgAffectedColumns,
                                msgAffectedRowCount,
                                msgContent,
                            )

                    settings.appLogger.debug("|   deletedRowCount: {0}".format(deletedRowCount))

        self.supportConnection.connection.commit()

        return (successCount, exceptionCount, errorCount, warningCount, ignoredCount, noticeCount)
Пример #4
0
def getClosureScript(specification):

    script = ""
    for thisRecord in specification.records:
        if thisRecord.parentKeyColumns is not None:
            if len(thisRecord.parentKeyColumns)>0:

                script = script + "CREATE TABLE ctree.%s_%s_closure (\n" %(thisRecord.table,  cs.delimitedStringList(thisRecord.primaryKeyColumns,"_"))
                
                for thisColumn in thisRecord.primaryKeyColumns:
                    for thisField in thisRecord.fields:
                        if thisColumn == thisField.column:
                            script = script + "  parent_%s %s,\n" %(thisColumn, thisField.strippedColumnClause(None, True))

                for thisColumn in thisRecord.primaryKeyColumns:
                    for thisField in thisRecord.fields:
                        if thisColumn == thisField.column:
                            script = script + "  child_%s %s,\n" %(thisColumn, thisField.strippedColumnClause(None, True))
                
                script = script + "  depth smallint NOT NULL);\n\n" 
            
    return(script)