mysql python emoji 表情存储

By godwind at 2017-11-16 • 0人收藏 • 3159人看过

修改包含emoji标签的字段格式为 utf8mb4

修改数据库连接编码为 utf8mb4

ALTER TABLE `core_pathology_reply` MODIFY `message` mediumtext CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;

2 个回复 | 最后更新于 2018-11-07
2017-12-14   #1

repr()

eval()

2018-11-07   #2

        self._cursor = self._conn.cursor()

        #数据库支持 emoji表情

        if config.DBCHAR_extra == 'utf8mb4':

            self._cursor.execute('SET NAMES utf8mb4')

            self._cursor.execute("SET CHARACTER SET utf8mb4")

            self._cursor.execute("SET character_set_connection=utf8mb4")


登录后方可回帖