def none_as_sql(_value, _db_type, _none_value='', _error=None):
    """Raises an error or returns a value if blank"""
    if _value is not None:
        return _value.as_sql(_db_type)
    elif _error is not None:
        raise Exception(_error)
    else:
        return _none_value
