veekun / pokedex

more than you ever wanted to know about Pokémon
MIT License
1.44k stars 637 forks source link

characterset mysql #192

Open mrbraca15 opened 7 years ago

mrbraca15 commented 7 years ago

hello people, I could load the data on mysql database with the following command pokedex load -e mysql+mysqldb://root@localhost/databasename, but there are tables like move_names that contains register with strange characters,¿how can I load the data with the correct character set? I need the data in english and spanish too.

eevee commented 7 years ago

Um, good question. MySQL has like half a dozen different places to set the character set; we should be setting them correctly when we can, but it's possible your server or connection has a goofy setting.

What does SHOW VARIABLES LIKE 'character_set%'; produce?

mrbraca15 commented 7 years ago

produce this

Variable_name Value


character_set_client utf8
character_set_connection utf8
character_set_database utf8
character_set_filesystem binary
character_set_results utf8
character_set_server latin1
character_set_system utf8
character_sets_dir C:\xampp\mysql\share\charsets\

miguelsotobaez commented 6 years ago

I found the solution for this problem, adding a charset variable in your SQLAlchemy connection.

Example: pokedex load -e mysql+pymysql://admin:password@localhost/database?charset=utf8

Regards

rluzuriaga commented 4 years ago

If anyone has this issue and the above comments didn't solve it, here are the steps I just used to solve it. Enter the mysql terminal and enter:

SELECT default_character_set_name FROM information_schema.SCHEMATA S WHERE schema_name = "DBNAME";

Change DBNAME to the database name you had created. This was my output:

+----------------------------+
| default_character_set_name |
+----------------------------+
| latin1                     |
+----------------------------+
1 row in set (0.00 sec)

Now enter this command changing DBNAME to your database name again:

ALTER DATABASE DBNAME CHARACTER SET utf8 COLLATE utf8_general_ci;

After I did that I was able to load using pokedex load -e mysql+pymysql://admin:password@localhost/database