def _mysql_int_length(subtype):
    """Determine smallest field that can hold data with given length."""

    try:
        length = int(subtype)
    except ValueError:
        raise ValueError(
            'Invalid subtype for Integer column: {}'.format(subtype)
        )

    if length < 3:
        kind = 'TINYINT'
    elif length < 4:
        kind = 'SMALLINT'
    elif length < 7:
        kind = 'MEDIUMINT'
    elif length <= 10:
        kind = 'INT'
    else:
        kind = 'BIGINT'

    return '{}({})'.format(kind, length)