From a8884baa3aeba7e3cb91709aa17411b66a0b42f8 Mon Sep 17 00:00:00 2001 From: MarkusJoe Date: Sun, 2 Oct 2022 17:29:46 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E4=BA=86=E5=AF=B9R?= =?UTF-8?q?edis=E6=95=B0=E6=8D=AE=E5=BA=93=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/db/__init__.py | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/src/db/__init__.py b/src/db/__init__.py index 813821d..4238412 100644 --- a/src/db/__init__.py +++ b/src/db/__init__.py @@ -11,30 +11,6 @@ from src.config import Config database = Config.database - -def split_(origin: str, type_: int = 0) -> dict: - """ - - :param origin: - :param type_: 0 -> Mysql - :return: - """ - origin = origin.split('://')[-1] - host = origin.split('@')[-1].split('/')[0].split(':')[0] - port = origin.split('@')[-1].split('/')[0].split(':')[1] - if type_ == 0: # Mysql - database_ = origin.split('@')[-1].split('/')[-1] - user = origin.split('@')[0].split(':')[0] - password = origin.split('@')[0].split(':')[1] - return { - 'host': host, - 'port': port, - 'database': database_, - 'user': user, - 'password': password - } - - if database == 'sqlite': import sqlite3 as operator from src.utils.t_download import download @@ -42,12 +18,7 @@ if database == 'sqlite': if not os.path.exists('./src/db/data.sqlite'): download('https://markusjoe.github.io/static_file_hosting/static/counter/data.sqlite') from src.db.db import SQLite as Database -else: - import pymysql as operator - - result = split_(database) - for k, v in zip(result.keys(), result.values()): - os.environ[f"m_{k}"] = v - from src.db.db import MySQL as Database - +elif 'redis' in database: + import redis as operator + from src.db.db import Redis as Database __all__ = [Database, operator]