I've got a node.js script running that pulls data out of a public "database" (it's a 'blockchain') and then performs some operations on it and then inserts it into a MySQL database. I've got the MySQL database using UTF8_general_ci
encoding. The vast majority of data parses fine, but every so often it hits something it can't insert. I get this error:
code: 'ER_TRUNCATED_WRONG_VALUE_FOR_FIELD',
errno: 1366,
sqlMessage: 'Incorrect string value: \'\\xF0\\x9F\\x8D\\x95 N...\' for column \'body\' at row 1',
sqlState: 'HY000',
index: 0,
It shows the bit of string that seems to be causing the error, and it always has this distinct question mark character:
This looks like Paradise for me! ����\
I'm guessing this is an encoding issue? Is there a way I can convert these before it throws an error? I'm not sure what encoding this blockchain uses, and I'm not even sure how I'd find out.
edit: here's what another example (of the error) shows on the web interface to this blockchain:
And your very welcome !
another edit: I should point out that I am using mysql.format(sql, inserts)
to handle inadvertent sql problems with the data -https://github.com/mysqljs/mysql#preparing-queries