def __init__(self, db): self.db = db # dicts of shard ID to dicts of model: count self._expected_data = { shard_id: defaultdict(lambda: 0) for shard_id in partition_config.get_shards_on_db(db) } self._unexpected_data = defaultdict(lambda: defaultdict(lambda: 0))
def get_count_of_unmatched_models_by_shard(database, model): """ Get counts of any `model` data residing on shards that aren't expected to live in `database`. Returns a list of tuples of the format: [ (shard_id, count_of_unexpected_models), ] The list will be empty if no invalid data is found. """ cursor = connections[database].cursor() query = _get_unmatched_shard_count_query(model) valid_shards = partition_config.get_shards_on_db(database) cursor.execute(query, [valid_shards]) results = cursor.fetchall() return results
def get_count_of_unmatched_models_by_shard(database, model): """ Get counts of any `model` data residing on shards that aren't expected to live in `database`. Returns a list of tuples of the format: [ (shard_id, count_of_unexpected_models), ] The list will be empty if no invalid data is found. """ cursor = connections[database].cursor() query = _get_unmatched_shard_count_query_for_testing(model) valid_shards = partition_config.get_shards_on_db(database) cursor.execute(query, [valid_shards]) results = cursor.fetchall() return results