google CloudSQL mysql emoji(1366,“第1行的列'name'的字符串值不正确:'\\xF0\\x9F\\x98\\x80\\xF0\\x9F…”)

2024-04-29 10:33:45 发布

您现在位置:Python中文网/ 问答频道 /正文

当我使用我的-appspot.com应用程序 但是当我在GAE上使用相同的库在本地运行它python manage.py runserver时,一切都能完美地工作,我可以发布和检索emojis。在

这是我的设置

import os
if os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine'):
    # Running on production App Engine, so use a Google Cloud SQL database.
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'HOST': '/cloudsql/my-app:us-central1:my-app-mysql',
            'NAME': '********',
            'USER': 'root',
            'PASSWORD': '*********',
        }
    }
else:
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'NAME': '*******',
            'USER': 'root',
            'PASSWORD': '*********',
            'HOST': '**********',
            'PORT': '3306',
            'OPTIONS': {
                 'charset': 'utf8mb4',
            }
        }
    }

以下是使用云shell时的字符集

^{pr2}$

这是我从另一个客户机使用数据库的IP连接时的字符集

Variable_name                        Value
character_set_client                utf8
character_set_connection            utf8mb4
character_set_database              utf8mb4
character_set_filesystem            binary
character_set_results               utf8
character_set_server                utf8mb4
character_set_system                utf8
collation_connection                utf8mb4_unicode_ci
collation_database                  utf8mb4_general_ci
collation_server                    utf8mb4_general_ci

我错过了什么?!!在

我怎么工作?在

谢谢 https://github.com/GoogleCloudPlatform/appengine-django-skeleton/issues/28


Tags: djangocomciappdefaultosgooglemysql
1条回答
网友
1楼 · 发布于 2024-04-29 10:33:45

waprin: @EssaAlshammri reproduced, filed internal bug with engineering team, will keep you updated.

来自github issue

You can try base64 encoding going in and out of the database as a workaround.

很好用。在

你可以等到他们解决这个问题

相关问题 更多 >