def sanitize(value, surround=True):
    """
    Sanitize a table or column name by replacing square and round brackets with
    curly ones and optionally surrounding the whole string in square brackets.

    Args:
        value (str): the value to sanitize
        surround (bool, optional): whether to surround the result in square
            brackets. Defaults to ``True``.
    """
    for o, n in zip('[()]', '{{}}'):
        value = value.replace(o, n)
    return '[{}]'.format(value) if surround else value
