python操作mysql出现错误

python操作mysql出现错误,求教大神这是为什么?另外怎么关闭autoflush?

数据库操作失败,具体信息是(raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely) (pymysql.err.InternalError) (1366, "Incorrect string value: '\\xF0\\x9F\\x99\\x83 \\xE2...' for column 'weibo_cont' at row 1") [SQL: 'INSERT INTO weibo_data (weibo_id, weibo_cont, repost_num, comment_num, praise_num, uid, is_origin, device, weibo_url, create_time, comment_crawled, repost_crawled) VALUES (%(weibo_id)s, %(weibo_cont)s, %(repost_num)s, %(comment_num)s, %(praise_num)s, %(uid)s, %(is_origin)s, %(device)s, %(weibo_url)s, %(create_time)s, %(comment_crawled)s, %(repost_crawled)s)'] [parameters: {'is_origin': 1, 'uid': '2273624057', 'weibo_cont': '做一个老粉丝。不吵不闹,保持微笑\U0001f643 \u200b\u200b\u200b\u200b', 'repost_crawled': 0, 'weibo_id': '4096027114076851', 'comment_num': 0, 'repost_num': 0, 'weibo_url': 'http://weibo.com/2273624057/EEi6rh6zF?from=page_1005052273624057_profile&wvr=6&mod=weibotime', 'device': 'iPhone 6 Plus', 'create_time': '2017-04-13 11:00', 'comment_crawled': 0, 'praise_num': 0}]
阅读 8.4k
2 个回答

你这是插入汉字吧,编码问题 设置数据库编码格式utf-8

貌似是你的数据格式不低

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题