google CloudSQL mysql 表情符号(1366,"Incorrect string value: '\xF0\x9F\x98\x80\xF0\x9F...' for column 'name' at row 1")
google CloudSQL mysql emoji (1366, "Incorrect string value: '\\xF0\\x9F\\x98\\x80\\xF0\\x9F...' for column 'name' at row 1")
当我使用 my-app.appspot.com 时,我无法将 post 表情符号发送到数据库
但是当我 运行 在本地 python manage.py runserver
使用 GAE 上的相同库时,一切都完美无缺,我可以 post 并检索表情符号。
这是我的设置.py
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
mysql> SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';
+--------------------------+--------------------+
| Variable_name | Value |
+--------------------------+--------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| collation_connection | utf8_general_ci |
| collation_database | utf8mb4_general_ci |
| collation_server | utf8mb4_general_ci |
+--------------------------+--------------------+
10 rows in set (0.15 sec)
这是我从另一个客户端使用数据库的 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
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.
它工作正常。
你可以等到他们解决问题
当我使用 my-app.appspot.com 时,我无法将 post 表情符号发送到数据库
但是当我 运行 在本地 python manage.py runserver
使用 GAE 上的相同库时,一切都完美无缺,我可以 post 并检索表情符号。
这是我的设置.py
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
mysql> SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';
+--------------------------+--------------------+
| Variable_name | Value |
+--------------------------+--------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| collation_connection | utf8_general_ci |
| collation_database | utf8mb4_general_ci |
| collation_server | utf8mb4_general_ci |
+--------------------------+--------------------+
10 rows in set (0.15 sec)
这是我从另一个客户端使用数据库的 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
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.
它工作正常。
你可以等到他们解决问题