def multiShardExec(sql): """Execute a statement across all shards.""" from sh_util.sharding import ShardedResource from . import db_exec for connectionName in ShardedResource.allShardConnectionNames(): db_exec(sql, using=connectionName)
def _resolveConnectionsOrShards(connections=None): """ When connections is None, all shards will be returned, otherwise connections is returned unmodified. @param connections mixed List of connection names or Dict of handle->psqlConnectionString. Defaults to None. If None, all primary shard connections will be used. """ if connections is None: # Default to all shards. from sh_util.sharding import ShardedResource return ShardedResource.allShardConnectionNames() else: return connections