I use the following Python code to insert a row into a MySQL table:
city = City()
city.country_id = connection.globe.session.query(Country).\
filter(Country.code == row[1]).one().id
city.name = row[3].decode('latin1').encode('utf8')
city.province = row[2].decode('latin1').encode('utf8')
[city.latitude, city.longitude] = [row[5], row[6]]
connection.globe.session.add(city)
connection.globe.session.commit()
When testing on my local machine, an example row is inserted correctly:
75,209,36,Radès,36.7681,10.2753
Using the same code from a different machine (AWS) results in a slightly different row:
75,209,36,Radès,36.7681,10.2753
The entirety of the MySQL database is configured to use utf8mb4 encoding and I actually spent a significant amount of time believing that MySQL was to blame for the encoding error. But since I've been running it on different machines, I've noticed that the same code works on one machine, but not another.
Since the same code is being executed, I don't believe my Python code is to blame.
Is there something strange with Linux and character sets / character encoding that I'm missing here?
EDIT: I should note that they are connecting to the same RDS Database, meaning that the database is consistent between both inserts.