0

I'm new to MySQL and am writing text data to a database and get this error:

mysql.connector.errors.DatabaseError: 1366 (HY000): Incorrect string value: '\xCC\xB5#821...' for column 'column' at row 1

But when I decode that text in Python, it doesn't throw any errors:

In: b'\xCC\xB5#821...'.decode('utf-8')
Out: '̵#821...'

This answer seems to indicate that this code would throw an error, but it's not. What am I missing?

snapcrack
  • 1,761
  • 3
  • 20
  • 40

1 Answers1

0

I wasn't aware that the default character set is not actually UTF-8. Using ALTER TABLE <table> CONVERT TO CHARACTER SET utf8mb4, as indicated by other answers, fixed the problem.

snapcrack
  • 1,761
  • 3
  • 20
  • 40