2
我可以當我使用my-app.appspot.com 但是當我在GAE上使用相同的庫在本地運行它時,它不會將emojis發佈到數據庫,所有工作都很完美,我可以發佈和檢索emojis。谷歌CloudSQL mysql表情符(1366,「不正確的字符串值:'\ xF0 \ x9F \ x98 \ x80 \ xF0 \ x9F ...'列1'的名稱')
這裏是我設置的.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',
}
}
}
這裏是字符集使用雲殼
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