public function run()
    {
        $states = $state_names = $counties = [];
        $id_states = $id_counties = 0;

        foreach ($this->data['states'] as $state) {
            $states[] = sprintf(
                "(%s, %s, '%s', '%s')",
                ++$id_states,
                $this->data['country'],
                $state['code'],
                str_replace("'", "\\'", $state['name'])
            );
            foreach ($state['counties'] as $county) {
                $counties[$id_states][] = sprintf(
                    "(%s, %s, '%s')",
                    ++$id_counties,
                    $id_states,
                    str_replace("'", "\\'", $county)
                );
            }
            $state_names[$id_states] = $state['name'];
        }

        $count = count($this->data['states']);
        $states_sql = "-- $count State" . ($count > 1 ? 's' : '') . ":\n\n"
            . self::generateChunks(
                'INSERT INTO `states` (`id`, `country`, `code`, `name`) VALUES',
                $states
            );

        $counties_sql = '';
        foreach ($counties as $id => $block) {
            $counties_sql .= "-- $state_names[$id]\n\n"
                . self::generateChunks(
                    'INSERT INTO `counties` (`id`, `state`, `name`) VALUES',
                    $block
                );
        }

        return $states_sql . $counties_sql;
    }