micwho's blog

If you want to keep a secret, you must also hide it from yourself.

MySQLdb Incorrect string value error

2017-08-19 00:00:00 +0000

While I inserted some data to mysql using MySQLdb(python2.7), got an error as below:

Traceback (most recent call last):
  File "test.py", line 51, in <module>
    user(i)
  File "test.py", line 28, in user
    cursor.execute(sql)
  File "/usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/usr/local/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1366, "Incorrect string value: '\\xF0\\x9F\\x8F\\x8E K...' for column 'bio' at row 1") 

Hello

2017-08-02 00:00:00 +0000

Hello world!