def get_str_comparison_term(args, db_name, arg_name=None):
    """
    Return an SQL WHERE term for the named argument.

    :param str db_name: database column name
    :param str arg_name: command-line argument name

    :return: (sql_term, value).
    :rtype: (str, str)
    """
    arg_name = arg_name or db_name
    val = getattr(args, arg_name)
    eq = getattr(args, '_eq_' + arg_name, False)
    if eq or args.eq:
        op = '=='
        wildcard = ''
    elif args.like:
        op = 'LIKE'
        wildcard = '%'
    elif args.regex:
        op = 'REGEXP'
        wildcard = '.*'
    else:
        op = 'glob'
        wildcard = '*'
    where = ('{} {} ?'.format(db_name, op))
    val = val if args.exact else '{1}{0}{1}'.format(val, wildcard)
    if args.regex:
        val += '$'
    return (where, val)