From 7717ccac07a1a684088cdab9b5221525417d6e0a Mon Sep 17 00:00:00 2001 From: Qihang Zhang Date: Sat, 5 Apr 2025 01:02:15 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20fix(utils.py):=20?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0MySQL=E8=BF=9E=E6=8E=A5=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/utils.py b/utils.py index e51654d..417c4ca 100644 --- a/utils.py +++ b/utils.py @@ -8,11 +8,22 @@ from datetime import datetime, timedelta def load_config(): config_path = 'config.yaml' if not os.path.exists(config_path): - config = {'tushare_token': 'sk - tushare token'} + config = { + 'tushare_token': 'your_token_here', + 'mysql': { + 'user': 'user', + 'password': 'password', + 'host': '127.0.0.1', + 'port': 3306, + 'database': 'tushare', + 'charset': 'utf8' + } + } with open(config_path, 'w') as f: yaml.dump(config, f) - print(f"请在 {config_path} 中填入您的 tushare token") + print(f"请在 {config_path} 中填入您的 tushare token 和 MySQL 连接信息") exit(1) + with open(config_path, 'r') as f: config = yaml.safe_load(f) return config