From a74b565cc1d0cd0b2ee88cfc42e4840a872f97f8 Mon Sep 17 00:00:00 2001 From: MarkusJoe Date: Sun, 2 Oct 2022 17:29:00 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/config.py b/src/config.py index ab5ca48..ae09425 100644 --- a/src/config.py +++ b/src/config.py @@ -5,22 +5,23 @@ # @Create Time: 2022/9/11 # @File Name: config.py - import os class Config: """ - database type. Default is sqlite - database file path is "./src/db/data.sqlite", it is not exists, before you run server first - remote sqlite file url is "https://pac.rtst.tech/static_file_hosting/static/counter/data.sqlite" - you can download it manually - if you want to use mysql then replace "mysql://[Username]:[password]@[host]:[port]/[database]" with "sqlite" - example: mysql://root:114514@127.0.0.1:3306/homo + Available database: sqlite3, Redis. + Redis: "redis://host:port@password". + If your database doesn't have password, just don't type "@password". + Don't type ":" to use default port. """ - database = "mysql://counter:114514@111.173.80.154:26098/Counter" - # database = 'sqlite' - if 'sqlite' in database: - os.environ['counter_db_type'] = 'sqlite' - elif 'mysql' in database: - os.environ['counter_db_type'] = 'mysql' + database = "sqlite" # Database type + if 'redis' in database: + os.environ['c_not_full'] = "True" # Not full API supported. + os.environ['c_host'] = database.split('://')[-1].split(':')[0] + if ':' not in database.split('://'): + os.environ['c_port'] = '6379' + else: + os.environ['c_port'] = database.split('://')[-1].split('@')[0].split(':')[-1] + if '@' in database: + os.environ['c_password'] = database.split('://')[-1].split(':')[-1].split('@')[-1]