def _iterTroves(self, pristine, instanceIds, withFiles = True,
                    withDeps = True, errorOnMissing=True,
                    withFileObjects = False):
        instanceIds = list(instanceIds)

        if withFileObjects:
            troveClass = trove.TroveWithFileObjects
        else:
            troveClass = trove.Trove

        cu = self.db.cursor()
        cu.execute("""CREATE TEMPORARY TABLE getTrovesTbl(
                                idx %(PRIMARYKEY)s,
                                instanceId INT)
                   """ % self.db.keywords, start_transaction = False)

        cu.executemany("INSERT INTO getTrovesTbl VALUES (?, ?)",
                       list(enumerate(instanceIds)), start_transaction=False)

        cu.execute("""SELECT idx, troveName, version, flavor, timeStamps
                      FROM getTrovesTbl
                      JOIN Instances USING(instanceId)
                      JOIN Versions USING(versionId)
                      JOIN Flavors ON (Instances.flavorId = Flavors.flavorId)
                  """)

        versionCache = VersionCache()
        flavorCache = FlavorCache()
        results = [ None for x in instanceIds ]

        for idx, troveName, versionStr, flavorStr, timeStamps in cu:
            troveFlavor = flavorCache.get(flavorStr)
            troveVersion = versionCache.get(versionStr, timeStamps)

            trv = troveClass(troveName, troveVersion, troveFlavor, None,
                             setVersion = False)
            results[idx] = trv

        # add all of the troves which are references from this trove; the
        # flavor cache is already complete
        cu = self.db.cursor()
        if pristine:
            pristineClause = "TroveTroves.inPristine = 1"
        else:
            pristineClause = "Instances.isPresent = 1"

        cu.execute("""
            SELECT idx, troveName, version, flags, timeStamps, flavor
                FROM getTrovesTbl
                JOIN TroveTroves USING(instanceId)
                JOIN Instances
                JOIN Versions ON
                    Versions.versionId = Instances.versionId
                JOIN Flavors ON
                    TroveTroves.includedId = Instances.instanceId AND
                    Flavors.flavorId = Instances.flavorId
                WHERE %s
                ORDER BY idx
        """ % pristineClause)

        for idx, name, versionStr, flags, timeStamps, flavorStr in cu:
            version = versionCache.get(versionStr, timeStamps)
            flavor = flavorCache.get(flavorStr)

            byDefault = (flags & schema.TROVE_TROVES_BYDEFAULT) != 0
            weakRef = (flags & schema.TROVE_TROVES_WEAKREF) != 0

            results[idx].addTrove(name, version, flavor, byDefault = byDefault,
                                  weakRef = weakRef)

        for idx, instanceId in enumerate(instanceIds):
            trv = results[idx]

            if withDeps:
                self.depTables.get(cu, trv, instanceId)
            self.troveInfoTable.getInfo(cu, trv, instanceId)
            if not withFiles:
                yield trv

        if not pristine or withFiles:
            if withFileObjects:
                streamStr = "stream"
            else:
                streamStr = "NULL"

            cu.execute("""SELECT idx, pathId, path, version, fileId, isPresent,
                          %s
                          FROM getTrovesTbl
                          JOIN DBTroveFiles USING(instanceId)
                          JOIN Versions ON
                              Versions.versionId = DBTroveFiles.versionId
                          ORDER BY idx
                          """ % streamStr)
            curIdx = 0
            for (idx, pathId, path, version, fileId, isPresent, stream) in cu:
                if not pristine and not isPresent:
                    continue
                version = versions.VersionFromString(version)
                results[idx].addFile(pathId, path, version, fileId)
                if stream:
                    results[idx].addFileObject(fileId,
                                               files.ThawFile(stream, pathId))
                while idx != curIdx:
                    yield results[curIdx]
                    curIdx += 1

            while curIdx < len(results):
                if not pristine:
                    results[idx].computePathHashes()
                if not withFiles:
                    results[idx].removeAllFiles()

                yield results[curIdx]
                curIdx += 1

        cu.execute("DROP TABLE getTrovesTbl", start_transaction = False)
Fit the ith row to the db
dataset/ETHPy150Open sassoftware/conary/conary/local/sqldb.py/Database._iterTroves--crossover with--dataset/ETHPy150Open taoliu/taolib/Assoc/tables.py/Summary.fit_to_db