# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/01_utils.ipynb.

# %% auto 0
__all__ = ['quote_symbol', 'to_sql', 'execute', 'delegates']

# %% ../nbs/01_utils.ipynb 2
def quote_symbol(quote):
    """generate quote symbol to use for tables and columns"""
    if type(quote) == str:
        return quote
    else:
        if quote == True:
            return '"'
        else:
            return ''


def to_sql(l):
    if type(l) == list:
        return '(' + ', '.join([f"{item}" if type(item) in (int, float) else f"'{item}'" for item in l]) + ')'
    else:
        raise ValueError(f"type {type(l)} for l is not implemented!")
    return l


def execute(obj, **kwargs):
    """Call the exec method of `obj` if it exists, otherwise return the string representation of `obj`"""
    if hasattr(obj, 'execute'):
        return obj.execute(**kwargs)
    else:
        return obj

# %% ../nbs/01_utils.ipynb 4
def delegates(to):
    """Decorator: replace func name, signature and docstring with `to`'s."""
    import inspect
    from fastcore.docments import qual_name
    def _f(f):
        f.__name__ = to.__name__
        f.__qualname__ = qual_name(to)
        f.__signature__ = inspect.signature(to)
        f.__doc__ = to.__doc__
        return f
    return _f
