michaeldrennen / Geonames

A Laravel (php) package to interface with the geo-location services at geonames.org.
MIT License
89 stars 38 forks source link

Invalid utf8 character string #48

Closed zek closed 1 year ago

zek commented 3 years ago

I'm getting error as following when I execute php artisan geonames:install --country=TR --country=US

File: /home/forge/app/storage/geonames/TR.txt

Combining TR.txt 10669811/10669811 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
File: /home/forge/app/storage/geonames/US.txt

Combining US.txt 302388147/302388147 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Num Lines: 2323203

Starting to insert the records found in /home/forge/app/storage/geonames/master.txt
We are going to try to insert 2323202 geoname records.
Dropping the temp table named geonames_working (if it exists).
Creating the temp table named geonames_working
Running the LOAD DATA INFILE query...
SQLSTATE[HY000]: General error: 1300 Invalid utf8 character string: ''Iowa,Aioua,Aiova,Ajov,Ajova,Ajovae,Ajovo,Ayova,Ayowa,Hawkeye St'
daglob commented 3 years ago

@michaeldrennen, since the repository is closed for committing and pushing branches, I'll leave a comment here:

up code form

// src/Console/InsertGeonames.php:358

        $query = "LOAD DATA LOCAL INFILE '" . $localFilePath . "'
    INTO TABLE " . self::TABLE_WORKING . "

to

// src/Console/InsertGeonames.php:358

        // Set the charset of the required environment
        $charset = config("database.connections.{$this->connectionName}.charset", 'utf8mb4');

        $query = "LOAD DATA LOCAL INFILE '" . $localFilePath . "'
    INTO TABLE ".self::TABLE_WORKING." CHARACTER SET '{$charset}'
leonid-chernyavskiy commented 2 years ago

https://dba.stackexchange.com/questions/145080/import-geonames-allcountries-txt-into-mysql-5-7-using-load-infile-error-1300