Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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
Exemplo n.º 4
0
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)