From e5c7a81ce3b8b4701284f206d0dfba0cdc1f1e7e Mon Sep 17 00:00:00 2001 From: SM-Tech Date: Fri, 8 Dec 2023 09:05:58 +0800 Subject: [PATCH] fix ascii codec error, by using utf8 (#1608) Co-authored-by: crazywoola <427733928@qq.com> --- api/config.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/config.py b/api/config.py index 048af509ce..93856ff8a0 100644 --- a/api/config.py +++ b/api/config.py @@ -15,6 +15,7 @@ DEFAULTS = { 'DB_HOST': 'localhost', 'DB_PORT': '5432', 'DB_DATABASE': 'dify', + 'DB_CHARSET': 'utf8mb4', 'REDIS_HOST': 'localhost', 'REDIS_PORT': '6379', 'REDIS_DB': '0', @@ -148,10 +149,10 @@ class Config: # ------------------------ db_credentials = { key: get_env(key) for key in - ['DB_USERNAME', 'DB_PASSWORD', 'DB_HOST', 'DB_PORT', 'DB_DATABASE'] + ['DB_USERNAME', 'DB_PASSWORD', 'DB_HOST', 'DB_PORT', 'DB_DATABASE', 'DB_CHARSET''] } - self.SQLALCHEMY_DATABASE_URI = f"postgresql://{db_credentials['DB_USERNAME']}:{db_credentials['DB_PASSWORD']}@{db_credentials['DB_HOST']}:{db_credentials['DB_PORT']}/{db_credentials['DB_DATABASE']}" + self.SQLALCHEMY_DATABASE_URI = f"postgresql://{db_credentials['DB_USERNAME']}:{db_credentials['DB_PASSWORD']}@{db_credentials['DB_HOST']}:{db_credentials['DB_PORT']}/{db_credentials['DB_DATABASE']}?client_encoding={db_credentials['DB_CHARSET']}" self.SQLALCHEMY_ENGINE_OPTIONS = { 'pool_size': int(get_env('SQLALCHEMY_POOL_SIZE')), 'pool_recycle': int(get_env('SQLALCHEMY_POOL_RECYCLE'))