def exportSetupMatrices(self, cursor): with transaction.atomic(using=self.database, savepoint=False): print("Exporting setup matrices...") starttime = time() cursor.execute("SELECT name FROM setupmatrix") primary_keys = set([ i[0] for i in cursor.fetchall() ]) cursor.executemany( "insert into setupmatrix \ (name,source,lastmodified) \ values(%s,%s,%s)", [ (i.name, i.source, self.timestamp) for i in frepple.setupmatrices() if i.name not in primary_keys and (not self.source or self.source == i.source) ]) cursor.executemany( "update setupmatrix \ set source=%s, lastmodified=%s \ where name=%s", [ (i.source, self.timestamp, i.name) for i in frepple.setupmatrices() if i.name in primary_keys and (not self.source or self.source == i.source) ]) print('Exported setupmatrices in %.2f seconds' % (time() - starttime))
def exportSetupMatrices(cursor): print("Exporting setup matrices...") starttime = time() cursor.execute("SELECT name FROM setupmatrix") primary_keys = set([ i[0] for i in cursor.fetchall() ]) cursor.executemany( "insert into setupmatrix \ (name,lastmodified) \ values(%s,%s)", [( i.name, timestamp ) for i in frepple.setupmatrices() if i.name not in primary_keys ]) cursor.executemany( "update setupmatrix \ set lastmodified=%s \ where name=%s", [( timestamp, i.name ) for i in frepple.setupmatrices() if i.name in primary_keys ]) transaction.commit(using=database) print('Exported setupmatrices in %.2f seconds' % (time() - starttime))
def matrixrules(): for m in frepple.setupmatrices(): for i in m.rules: yield m, i