diff --git a/.env.example b/.env.example index 5e6da1ce..e6d812e9 100644 --- a/.env.example +++ b/.env.example @@ -7,7 +7,8 @@ RELOAD_DIRS=[] RELOAD_INCLUDE=[] RELOAD_EXCLUDE=[] -# MySQL +# Database +DB_DRIVER_NAME=mysql+asyncmy DB_HOST=127.0.0.1 DB_PORT=3306 DB_USERNAME=user diff --git a/README.md b/README.md index 052c50b0..bc1b9c69 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ ## 环境需求 - Python 3.11+ -- MySQL +- MySQL or SQLite - Redis ## 使用方法 diff --git a/alembic.ini b/alembic.ini index d228d4b8..80ed2e75 100644 --- a/alembic.ini +++ b/alembic.ini @@ -56,8 +56,6 @@ version_path_separator = os # Use os.pathsep. Default configuration used for ne # output_encoding = utf-8 # sqlalchemy.url = driver://user:pass@localhost/dbname -sqlalchemy.url = mysql+asyncmy://%(DB_USERNAME)s:%(DB_PASSWORD)s@%(DB_HOST)s:%(DB_PORT)s/%(DB_DATABASE)s - [post_write_hooks] # post_write_hooks defines scripts or Python functions that are run diff --git a/alembic/env.py b/alembic/env.py index 66fe0860..c7963d42 100644 --- a/alembic/env.py +++ b/alembic/env.py @@ -7,22 +7,22 @@ from typing import Iterator from alembic import context from sqlalchemy import engine_from_config, pool -from sqlalchemy.engine import Connection +from sqlalchemy.engine import Connection, URL from sqlalchemy.ext.asyncio import AsyncEngine from sqlmodel import SQLModel -from core.config import config as BotConfig +from core.config import config as application_config from utils.const import CORE_DIR, PLUGIN_DIR, PROJECT_ROOT from utils.log import logger # this is the Alembic Config object, which provides # access to the values within the .ini file in use. -config = context.config +alembic_cfg = context.config # Interpret the config file for Python logging. # This line sets up loggers basically. -if config.config_file_name is not None: - fileConfig(config.config_file_name) # skipcq: PY-A6006 +if alembic_cfg.config_file_name is not None: + fileConfig(alembic_cfg.config_file_name) # skipcq: PY-A6006 def scan_models() -> Iterator[str]: @@ -40,7 +40,13 @@ def import_models(): try: import_module(pkg) # 导入 models except Exception as e: # pylint: disable=W0703 - logger.error("在导入文件 %s 的过程中遇到了错误: \n[red bold]%s: %s[/]", pkg, type(e).__name__, e, extra={"markup": True}) + logger.error( + "在导入文件 %s 的过程中遇到了错误: \n[red bold]%s: %s[/]", + pkg, + type(e).__name__, + e, + extra={"markup": True}, + ) # register our models for alembic to auto-generate migrations @@ -56,12 +62,17 @@ target_metadata = SQLModel.metadata # here we allow ourselves to pass interpolation vars to alembic.ini # from the application config module -section = config.config_ini_section -config.set_section_option(section, "DB_HOST", BotConfig.mysql.host) -config.set_section_option(section, "DB_PORT", str(BotConfig.mysql.port)) -config.set_section_option(section, "DB_USERNAME", BotConfig.mysql.username) -config.set_section_option(section, "DB_PASSWORD", BotConfig.mysql.password) -config.set_section_option(section, "DB_DATABASE", BotConfig.mysql.database) +sqlalchemy_url = alembic_cfg.get_main_option("sqlalchemy.url") +if sqlalchemy_url is None: + new_url = URL.create( + application_config.database.driver_name, + username=application_config.database.username, + password=application_config.database.password, + host=application_config.database.host, + port=application_config.database.port, + database=application_config.database.database, + ) + alembic_cfg.set_main_option("sqlalchemy.url", str(new_url)) def run_migrations_offline() -> None: @@ -76,7 +87,7 @@ def run_migrations_offline() -> None: script output. """ - url = config.get_main_option("sqlalchemy.url") + url = alembic_cfg.get_main_option("sqlalchemy.url") context.configure( url=url, target_metadata=target_metadata, @@ -104,7 +115,7 @@ async def run_migrations_online() -> None: """ connectable = AsyncEngine( engine_from_config( - config.get_section(config.config_ini_section), + alembic_cfg.get_section(alembic_cfg.config_ini_section), prefix="sqlalchemy.", poolclass=pool.NullPool, future=True, diff --git a/alembic/versions/9e9a36470cd5_init.py b/alembic/versions/9e9a36470cd5_init.py index b72315c5..2caf2953 100644 --- a/alembic/versions/9e9a36470cd5_init.py +++ b/alembic/versions/9e9a36470cd5_init.py @@ -128,7 +128,6 @@ def upgrade() -> None: sa.Column( "time_created", sa.DateTime(timezone=True), - server_default=sa.text("now()"), nullable=True, ), sa.Column("time_updated", sa.DateTime(timezone=True), nullable=True), @@ -146,10 +145,7 @@ def upgrade() -> None: ), nullable=True, ), - sa.ForeignKeyConstraint( - ["user_id"], - ["user.user_id"], - ), + sa.ForeignKeyConstraint(["user_id"], ["user.user_id"], "sign_1"), sa.PrimaryKeyConstraint("id", "user_id"), mysql_charset="utf8mb4", mysql_collate="utf8mb4_general_ci", diff --git a/alembic/versions/ddcfba3c7d5c_v4.py b/alembic/versions/ddcfba3c7d5c_v4.py index 9be68da5..396bbfe0 100644 --- a/alembic/versions/ddcfba3c7d5c_v4.py +++ b/alembic/versions/ddcfba3c7d5c_v4.py @@ -226,7 +226,6 @@ def upgrade() -> None: sa.Column( "create_time", sa.DateTime(timezone=True), - server_default=sa.text("now()"), nullable=True, ), sa.Column("last_save_time", sa.DateTime(timezone=True), nullable=True), @@ -240,8 +239,14 @@ def upgrade() -> None: op.drop_table(old_cookies_database_name1) op.drop_table(old_cookies_database_name2) op.drop_table("admin") - op.drop_constraint("sign_ibfk_1", "sign", type_="foreignkey") - op.drop_index("user_id", table_name="sign") + context = op.get_context() + if context.dialect.name == "sqlite": + with op.batch_alter_table("sign") as batch_op: + batch_op.drop_constraint("sign_1", type_="foreignkey") + op.drop_table("user") + return + op.drop_constraint("sign_1", "sign", type_="foreignkey") + op.drop_index("sign_1", table_name="sign") op.drop_table("user") # ### end Alembic commands ### @@ -302,8 +307,13 @@ def downgrade() -> None: mysql_default_charset="utf8mb4", mysql_engine="InnoDB", ) - op.create_foreign_key("sign_ibfk_1", "sign", "user", ["user_id"], ["user_id"]) - op.create_index("user_id", "sign", ["user_id"], unique=False) + context = op.get_context() + if context.dialect.name == "sqlite": + with op.batch_alter_table("sign") as batch_op: + batch_op.create_foreign_key("sign_1", type_="foreignkey") + else: + op.create_foreign_key("sign_1", "sign", "user", ["user_id"], ["user_id"]) + op.create_index("sign_1", "sign", ["user_id"], unique=False) op.drop_table("users") op.drop_table("players") op.drop_table("cookies") diff --git a/core/config.py b/core/config.py index 39872bdb..78cc902f 100644 --- a/core/config.py +++ b/core/config.py @@ -21,9 +21,10 @@ class JoinGroups(str, Enum): ALLOW_ALL = "ALLOW_ALL" -class MySqlConfig(Settings): - host: str = "127.0.0.1" - port: int = 3306 +class DatabaseConfig(Settings): + driver_name: str = "mysql+asyncmy" + host: Optional[str] = None + port: Optional[int] = None username: Optional[str] = None password: Optional[str] = None database: Optional[str] = None @@ -43,7 +44,7 @@ class RedisConfig(Settings): class LoggerConfig(Settings): - name: str = "TGPaimon" + name: str = "PaiGram" width: Optional[int] = None time_format: str = "[%Y-%m-%d %X]" traceback_max_frames: int = 20 @@ -146,7 +147,7 @@ class ApplicationConfig(Settings): pass_challenge_user_web: str = "" reload: ReloadConfig = ReloadConfig() - mysql: MySqlConfig = MySqlConfig() + database: DatabaseConfig = DatabaseConfig() logger: LoggerConfig = LoggerConfig() webserver: WebServerConfig = WebServerConfig() redis: RedisConfig = RedisConfig() diff --git a/core/dependence/mysql.py b/core/dependence/database.py similarity index 85% rename from core/dependence/mysql.py rename to core/dependence/database.py index a1b71b30..67dc156a 100644 --- a/core/dependence/mysql.py +++ b/core/dependence/database.py @@ -10,29 +10,30 @@ from core.base_service import BaseService from core.config import ApplicationConfig from core.sqlmodel.session import AsyncSession -__all__ = ("MySQL",) +__all__ = ("Database",) -class MySQL(BaseService.Dependence): +class Database(BaseService.Dependence): @classmethod def from_config(cls, config: ApplicationConfig) -> Self: - return cls(**config.mysql.dict()) + return cls(**config.database.dict()) def __init__( self, + driver_name: str, host: Optional[str] = None, port: Optional[int] = None, username: Optional[str] = None, password: Optional[str] = None, database: Optional[str] = None, ): - self.database = database + self.database = database # skipcq: PTC-W0052 self.password = password self.username = username self.port = port self.host = host self.url = URL.create( - "mysql+asyncmy", + driver_name, username=self.username, password=self.password, host=self.host, diff --git a/core/services/cookies/repositories.py b/core/services/cookies/repositories.py index a11b9d89..b0cc6894 100644 --- a/core/services/cookies/repositories.py +++ b/core/services/cookies/repositories.py @@ -4,7 +4,7 @@ from sqlmodel import select from core.base_service import BaseService from core.basemodel import RegionEnum -from core.dependence.mysql import MySQL +from core.dependence.database import Database from core.services.cookies.models import CookiesDataBase as Cookies from core.sqlmodel.session import AsyncSession @@ -12,8 +12,8 @@ __all__ = ("CookiesRepository",) class CookiesRepository(BaseService.Component): - def __init__(self, mysql: MySQL): - self.engine = mysql.engine + def __init__(self, database: Database): + self.engine = database.engine async def get( self, diff --git a/core/services/players/repositories.py b/core/services/players/repositories.py index 0bf4daa0..e88221d9 100644 --- a/core/services/players/repositories.py +++ b/core/services/players/repositories.py @@ -4,7 +4,7 @@ from sqlmodel import select, delete from core.base_service import BaseService from core.basemodel import RegionEnum -from core.dependence.mysql import MySQL +from core.dependence.database import Database from core.services.players.models import PlayerInfoSQLModel from core.services.players.models import PlayersDataBase as Player from core.sqlmodel.session import AsyncSession @@ -13,8 +13,8 @@ __all__ = ("PlayersRepository", "PlayerInfoRepository") class PlayersRepository(BaseService.Component): - def __init__(self, mysql: MySQL): - self.engine = mysql.engine + def __init__(self, database: Database): + self.engine = database.engine async def get( self, @@ -63,8 +63,8 @@ class PlayersRepository(BaseService.Component): class PlayerInfoRepository(BaseService.Component): - def __init__(self, mysql: MySQL): - self.engine = mysql.engine + def __init__(self, database: Database): + self.engine = database.engine async def get( self, diff --git a/core/services/quiz/repositories.py b/core/services/quiz/repositories.py index 28542e8f..c914c562 100644 --- a/core/services/quiz/repositories.py +++ b/core/services/quiz/repositories.py @@ -3,7 +3,7 @@ from typing import List from sqlmodel import select from core.base_service import BaseService -from core.dependence.mysql import MySQL +from core.dependence.database import Database from core.services.quiz.models import AnswerDB, QuestionDB from core.sqlmodel.session import AsyncSession @@ -11,8 +11,8 @@ __all__ = ("QuizRepository",) class QuizRepository(BaseService.Component): - def __init__(self, mysql: MySQL): - self.engine = mysql.engine + def __init__(self, database: Database): + self.engine = database.engine async def get_question_list(self) -> List[QuestionDB]: async with AsyncSession(self.engine) as session: diff --git a/core/services/sign/repositories.py b/core/services/sign/repositories.py index ef5d108a..9eccbc16 100644 --- a/core/services/sign/repositories.py +++ b/core/services/sign/repositories.py @@ -3,7 +3,7 @@ from typing import List, Optional from sqlmodel import select from core.base_service import BaseService -from core.dependence.mysql import MySQL +from core.dependence.database import Database from core.services.sign.models import Sign from core.sqlmodel.session import AsyncSession @@ -11,8 +11,8 @@ __all__ = ("SignRepository",) class SignRepository(BaseService.Component): - def __init__(self, mysql: MySQL): - self.engine = mysql.engine + def __init__(self, database: Database): + self.engine = database.engine async def add(self, sign: Sign): async with AsyncSession(self.engine) as session: diff --git a/core/services/users/repositories.py b/core/services/users/repositories.py index 71d963bc..64bb0906 100644 --- a/core/services/users/repositories.py +++ b/core/services/users/repositories.py @@ -3,7 +3,7 @@ from typing import Optional, List from sqlmodel import select from core.base_service import BaseService -from core.dependence.mysql import MySQL +from core.dependence.database import Database from core.services.users.models import UserDataBase as User from core.sqlmodel.session import AsyncSession @@ -11,8 +11,8 @@ __all__ = ("UserRepository",) class UserRepository(BaseService.Component): - def __init__(self, mysql: MySQL): - self.engine = mysql.engine + def __init__(self, database: Database): + self.engine = database.engine async def get_by_user_id(self, user_id: int) -> Optional[User]: async with AsyncSession(self.engine) as session: diff --git a/plugins/tools/genshin.py b/plugins/tools/genshin.py index 39e18dcc..afac56d3 100644 --- a/plugins/tools/genshin.py +++ b/plugins/tools/genshin.py @@ -15,7 +15,7 @@ from telegram.ext import ContextTypes from core.basemodel import RegionEnum from core.config import config -from core.dependence.mysql import MySQL +from core.dependence.database import Database from core.dependence.redisdb import RedisDB from core.error import ServiceNotFoundError from core.plugin import Plugin @@ -59,22 +59,22 @@ class CharacterDetailsSQLModel(SQLModel, table=True): class CharacterDetails(Plugin): def __init__( self, - mysql: MySQL, + database: Database, redis: RedisDB, ) -> None: - self.mysql = mysql + self.database = database self.redis = redis.client self.ttl = 60 * 60 * 6 async def initialize(self) -> None: def fetch_and_update_objects(connection): - if not self.mysql.engine.dialect.has_table(connection, table_name="character_details"): + if not self.database.engine.dialect.has_table(connection, table_name="character_details"): logger.info("正在创建角色详细信息表") table: "Table" = SQLModel.metadata.tables["character_details"] table.create(connection) logger.success("创建角色详细信息表成功") - async with self.mysql.engine.begin() as conn: + async with self.database.engine.begin() as conn: await conn.run_sync(fetch_and_update_objects) asyncio.create_task(self.save_character_details_task(max_ttl=None)) self.application.job_queue.run_daily(self.del_old_data_job, time(hour=3, minute=0)) @@ -89,7 +89,7 @@ class CharacterDetails(Plugin): async def del_old_data(self, expiration_time: timedelta): expire_time = datetime.now() - expiration_time statement = delete(CharacterDetailsSQLModel).where(CharacterDetailsSQLModel.time_updated <= expire_time) - async with AsyncSession(self.mysql.engine) as session: + async with AsyncSession(self.database.engine) as session: await session.execute(statement) async def save_character_details_task(self, max_ttl: Optional[int] = 60 * 60): @@ -120,7 +120,7 @@ class CharacterDetails(Plugin): logger.warning("Redis key[%s] 数据未找到", key) # 如果未找到可能因为处理过程中已经过期,导致该数据未回写到 MySQL continue str_data = str(data, encoding="utf-8") - async with AsyncSession(self.mysql.engine) as session: + async with AsyncSession(self.database.engine) as session: statement = ( select(CharacterDetailsSQLModel) .where(CharacterDetailsSQLModel.player_id == player_id) @@ -132,14 +132,14 @@ class CharacterDetails(Plugin): sql_data = CharacterDetailsSQLModel( player_id=player_id, character_id=character_id, data=str_data, time_updated=datetime.now() ) - async with AsyncSession(self.mysql.engine) as session: + async with AsyncSession(self.database.engine) as session: session.add(sql_data) await session.commit() else: if sql_data.time_updated <= datetime.now() - timedelta(hours=2): sql_data.data = str_data sql_data.time_updated = datetime.now() - async with AsyncSession(self.mysql.engine) as session: + async with AsyncSession(self.database.engine) as session: session.add(sql_data) await session.commit() @@ -170,7 +170,7 @@ class CharacterDetails(Plugin): uid: int, character_id: int, ) -> Optional["CalculatorCharacterDetails"]: - async with AsyncSession(self.mysql.engine) as session: + async with AsyncSession(self.database.engine) as session: statement = ( select(CharacterDetailsSQLModel) .where(CharacterDetailsSQLModel.player_id == uid) diff --git a/poetry.lock b/poetry.lock index f00ea455..29a1ad7c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry and should not be changed by hand. +# This file is automatically @generated by Poetry 1.4.1 and should not be changed by hand. [[package]] name = "aiofiles" @@ -151,6 +151,18 @@ files = [ [package.dependencies] frozenlist = ">=1.1.0" +[[package]] +name = "aiosqlite" +version = "0.18.0" +description = "asyncio bridge to the standard sqlite3 module" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "aiosqlite-0.18.0-py3-none-any.whl", hash = "sha256:c3511b841e3a2c5614900ba1d179f366826857586f78abd75e7cbeb88e75a557"}, + {file = "aiosqlite-0.18.0.tar.gz", hash = "sha256:faa843ef5fb08bafe9a9b3859012d3d9d6f77ce3637899de20606b7fc39aa213"}, +] + [[package]] name = "alembic" version = "1.10.2" @@ -735,7 +747,7 @@ tox = ["tox"] [[package]] name = "enkanetwork.py" -version = "1.4.1" +version = "1.4.2" description = "Library for fetching JSON data from site https://enka.network/" category = "main" optional = false @@ -752,7 +764,7 @@ pydantic = "*" type = "git" url = "https://github.com/mrwan200/EnkaNetwork.py" reference = "HEAD" -resolved_reference = "c42f2dee044a6cb6a037eeda20098b524aededb7" +resolved_reference = "68482c394bcce9d5e42896e4c3a17d0022283c7b" [[package]] name = "et-xmlfile" @@ -943,7 +955,7 @@ geetest = ["rsa"] type = "git" url = "https://github.com/thesadru/genshin.py" reference = "HEAD" -resolved_reference = "4c526970f4ed85a5055ebfb7cbe79455a45b6c2f" +resolved_reference = "4e96f8308fb3afd6a7d3353d1d3655aa3f95ea2a" [[package]] name = "gitdb" @@ -1209,14 +1221,14 @@ files = [ [[package]] name = "importlib-metadata" -version = "6.0.0" +version = "6.1.0" description = "Read metadata from Python packages" category = "main" optional = false python-versions = ">=3.7" files = [ - {file = "importlib_metadata-6.0.0-py3-none-any.whl", hash = "sha256:7efb448ec9a5e313a57655d35aa54cd3e01b7e1fbcf72dce1bf06119420f5bad"}, - {file = "importlib_metadata-6.0.0.tar.gz", hash = "sha256:e354bedeb60efa6affdcc8ae121b73544a7aa74156d047311948f6d711cd378d"}, + {file = "importlib_metadata-6.1.0-py3-none-any.whl", hash = "sha256:ff80f3b5394912eb1b108fcfd444dc78b7f1f3e16b16188054bd01cb9cb86f09"}, + {file = "importlib_metadata-6.1.0.tar.gz", hash = "sha256:43ce9281e097583d758c2c708c4376371261a02c34682491a8e98352365aad20"}, ] [package.dependencies] @@ -1611,14 +1623,14 @@ files = [ [[package]] name = "pathspec" -version = "0.11.0" +version = "0.11.1" description = "Utility library for gitignore style pattern matching of file paths." category = "main" optional = false python-versions = ">=3.7" files = [ - {file = "pathspec-0.11.0-py3-none-any.whl", hash = "sha256:3a66eb970cbac598f9e5ccb5b2cf58930cd8e3ed86d393d541eaf2d8b1705229"}, - {file = "pathspec-0.11.0.tar.gz", hash = "sha256:64d338d4e0914e91c1792321e6907b5a593f1ab1851de7fc269557a21b30ebbc"}, + {file = "pathspec-0.11.1-py3-none-any.whl", hash = "sha256:d8af70af76652554bd134c22b3e8a1cc46ed7d91edcdd721ef1a0c51a84a5293"}, + {file = "pathspec-0.11.1.tar.gz", hash = "sha256:2798de800fa92780e33acca925945e9a19a133b715067cf165b8866c15a31687"}, ] [[package]] @@ -1791,48 +1803,48 @@ files = [ [[package]] name = "pydantic" -version = "1.10.6" +version = "1.10.7" description = "Data validation and settings management using python type hints" category = "main" optional = false python-versions = ">=3.7" files = [ - {file = "pydantic-1.10.6-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f9289065611c48147c1dd1fd344e9d57ab45f1d99b0fb26c51f1cf72cd9bcd31"}, - {file = "pydantic-1.10.6-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:8c32b6bba301490d9bb2bf5f631907803135e8085b6aa3e5fe5a770d46dd0160"}, - {file = "pydantic-1.10.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fd9b9e98068fa1068edfc9eabde70a7132017bdd4f362f8b4fd0abed79c33083"}, - {file = "pydantic-1.10.6-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1c84583b9df62522829cbc46e2b22e0ec11445625b5acd70c5681ce09c9b11c4"}, - {file = "pydantic-1.10.6-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:b41822064585fea56d0116aa431fbd5137ce69dfe837b599e310034171996084"}, - {file = "pydantic-1.10.6-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:61f1f08adfaa9cc02e0cbc94f478140385cbd52d5b3c5a657c2fceb15de8d1fb"}, - {file = "pydantic-1.10.6-cp310-cp310-win_amd64.whl", hash = "sha256:32937835e525d92c98a1512218db4eed9ddc8f4ee2a78382d77f54341972c0e7"}, - {file = "pydantic-1.10.6-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:bbd5c531b22928e63d0cb1868dee76123456e1de2f1cb45879e9e7a3f3f1779b"}, - {file = "pydantic-1.10.6-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:e277bd18339177daa62a294256869bbe84df1fb592be2716ec62627bb8d7c81d"}, - {file = "pydantic-1.10.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:89f15277d720aa57e173954d237628a8d304896364b9de745dcb722f584812c7"}, - {file = "pydantic-1.10.6-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b243b564cea2576725e77aeeda54e3e0229a168bc587d536cd69941e6797543d"}, - {file = "pydantic-1.10.6-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:3ce13a558b484c9ae48a6a7c184b1ba0e5588c5525482681db418268e5f86186"}, - {file = "pydantic-1.10.6-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:3ac1cd4deed871dfe0c5f63721e29debf03e2deefa41b3ed5eb5f5df287c7b70"}, - {file = "pydantic-1.10.6-cp311-cp311-win_amd64.whl", hash = "sha256:b1eb6610330a1dfba9ce142ada792f26bbef1255b75f538196a39e9e90388bf4"}, - {file = "pydantic-1.10.6-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:4ca83739c1263a044ec8b79df4eefc34bbac87191f0a513d00dd47d46e307a65"}, - {file = "pydantic-1.10.6-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ea4e2a7cb409951988e79a469f609bba998a576e6d7b9791ae5d1e0619e1c0f2"}, - {file = "pydantic-1.10.6-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:53de12b4608290992a943801d7756f18a37b7aee284b9ffa794ee8ea8153f8e2"}, - {file = "pydantic-1.10.6-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:60184e80aac3b56933c71c48d6181e630b0fbc61ae455a63322a66a23c14731a"}, - {file = "pydantic-1.10.6-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:415a3f719ce518e95a92effc7ee30118a25c3d032455d13e121e3840985f2efd"}, - {file = "pydantic-1.10.6-cp37-cp37m-win_amd64.whl", hash = "sha256:72cb30894a34d3a7ab6d959b45a70abac8a2a93b6480fc5a7bfbd9c935bdc4fb"}, - {file = "pydantic-1.10.6-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:3091d2eaeda25391405e36c2fc2ed102b48bac4b384d42b2267310abae350ca6"}, - {file = "pydantic-1.10.6-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:751f008cd2afe812a781fd6aa2fb66c620ca2e1a13b6a2152b1ad51553cb4b77"}, - {file = "pydantic-1.10.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:12e837fd320dd30bd625be1b101e3b62edc096a49835392dcf418f1a5ac2b832"}, - {file = "pydantic-1.10.6-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:587d92831d0115874d766b1f5fddcdde0c5b6c60f8c6111a394078ec227fca6d"}, - {file = "pydantic-1.10.6-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:476f6674303ae7965730a382a8e8d7fae18b8004b7b69a56c3d8fa93968aa21c"}, - {file = "pydantic-1.10.6-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:3a2be0a0f32c83265fd71a45027201e1278beaa82ea88ea5b345eea6afa9ac7f"}, - {file = "pydantic-1.10.6-cp38-cp38-win_amd64.whl", hash = "sha256:0abd9c60eee6201b853b6c4be104edfba4f8f6c5f3623f8e1dba90634d63eb35"}, - {file = "pydantic-1.10.6-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:6195ca908045054dd2d57eb9c39a5fe86409968b8040de8c2240186da0769da7"}, - {file = "pydantic-1.10.6-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:43cdeca8d30de9a897440e3fb8866f827c4c31f6c73838e3a01a14b03b067b1d"}, - {file = "pydantic-1.10.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4c19eb5163167489cb1e0161ae9220dadd4fc609a42649e7e84a8fa8fff7a80f"}, - {file = "pydantic-1.10.6-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:012c99a9c0d18cfde7469aa1ebff922e24b0c706d03ead96940f5465f2c9cf62"}, - {file = "pydantic-1.10.6-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:528dcf7ec49fb5a84bf6fe346c1cc3c55b0e7603c2123881996ca3ad79db5bfc"}, - {file = "pydantic-1.10.6-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:163e79386c3547c49366e959d01e37fc30252285a70619ffc1b10ede4758250a"}, - {file = "pydantic-1.10.6-cp39-cp39-win_amd64.whl", hash = "sha256:189318051c3d57821f7233ecc94708767dd67687a614a4e8f92b4a020d4ffd06"}, - {file = "pydantic-1.10.6-py3-none-any.whl", hash = "sha256:acc6783751ac9c9bc4680379edd6d286468a1dc8d7d9906cd6f1186ed682b2b0"}, - {file = "pydantic-1.10.6.tar.gz", hash = "sha256:cf95adb0d1671fc38d8c43dd921ad5814a735e7d9b4d9e437c088002863854fd"}, + {file = "pydantic-1.10.7-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e79e999e539872e903767c417c897e729e015872040e56b96e67968c3b918b2d"}, + {file = "pydantic-1.10.7-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:01aea3a42c13f2602b7ecbbea484a98169fb568ebd9e247593ea05f01b884b2e"}, + {file = "pydantic-1.10.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:516f1ed9bc2406a0467dd777afc636c7091d71f214d5e413d64fef45174cfc7a"}, + {file = "pydantic-1.10.7-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ae150a63564929c675d7f2303008d88426a0add46efd76c3fc797cd71cb1b46f"}, + {file = "pydantic-1.10.7-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:ecbbc51391248116c0a055899e6c3e7ffbb11fb5e2a4cd6f2d0b93272118a209"}, + {file = "pydantic-1.10.7-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:f4a2b50e2b03d5776e7f21af73e2070e1b5c0d0df255a827e7c632962f8315af"}, + {file = "pydantic-1.10.7-cp310-cp310-win_amd64.whl", hash = "sha256:a7cd2251439988b413cb0a985c4ed82b6c6aac382dbaff53ae03c4b23a70e80a"}, + {file = "pydantic-1.10.7-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:68792151e174a4aa9e9fc1b4e653e65a354a2fa0fed169f7b3d09902ad2cb6f1"}, + {file = "pydantic-1.10.7-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:dfe2507b8ef209da71b6fb5f4e597b50c5a34b78d7e857c4f8f3115effaef5fe"}, + {file = "pydantic-1.10.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:10a86d8c8db68086f1e30a530f7d5f83eb0685e632e411dbbcf2d5c0150e8dcd"}, + {file = "pydantic-1.10.7-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d75ae19d2a3dbb146b6f324031c24f8a3f52ff5d6a9f22f0683694b3afcb16fb"}, + {file = "pydantic-1.10.7-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:464855a7ff7f2cc2cf537ecc421291b9132aa9c79aef44e917ad711b4a93163b"}, + {file = "pydantic-1.10.7-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:193924c563fae6ddcb71d3f06fa153866423ac1b793a47936656e806b64e24ca"}, + {file = "pydantic-1.10.7-cp311-cp311-win_amd64.whl", hash = "sha256:b4a849d10f211389502059c33332e91327bc154acc1845f375a99eca3afa802d"}, + {file = "pydantic-1.10.7-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:cc1dde4e50a5fc1336ee0581c1612215bc64ed6d28d2c7c6f25d2fe3e7c3e918"}, + {file = "pydantic-1.10.7-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e0cfe895a504c060e5d36b287ee696e2fdad02d89e0d895f83037245218a87fe"}, + {file = "pydantic-1.10.7-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:670bb4683ad1e48b0ecb06f0cfe2178dcf74ff27921cdf1606e527d2617a81ee"}, + {file = "pydantic-1.10.7-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:950ce33857841f9a337ce07ddf46bc84e1c4946d2a3bba18f8280297157a3fd1"}, + {file = "pydantic-1.10.7-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:c15582f9055fbc1bfe50266a19771bbbef33dd28c45e78afbe1996fd70966c2a"}, + {file = "pydantic-1.10.7-cp37-cp37m-win_amd64.whl", hash = "sha256:82dffb306dd20bd5268fd6379bc4bfe75242a9c2b79fec58e1041fbbdb1f7914"}, + {file = "pydantic-1.10.7-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:8c7f51861d73e8b9ddcb9916ae7ac39fb52761d9ea0df41128e81e2ba42886cd"}, + {file = "pydantic-1.10.7-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:6434b49c0b03a51021ade5c4daa7d70c98f7a79e95b551201fff682fc1661245"}, + {file = "pydantic-1.10.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:64d34ab766fa056df49013bb6e79921a0265204c071984e75a09cbceacbbdd5d"}, + {file = "pydantic-1.10.7-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:701daea9ffe9d26f97b52f1d157e0d4121644f0fcf80b443248434958fd03dc3"}, + {file = "pydantic-1.10.7-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:cf135c46099ff3f919d2150a948ce94b9ce545598ef2c6c7bf55dca98a304b52"}, + {file = "pydantic-1.10.7-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:b0f85904f73161817b80781cc150f8b906d521fa11e3cdabae19a581c3606209"}, + {file = "pydantic-1.10.7-cp38-cp38-win_amd64.whl", hash = "sha256:9f6f0fd68d73257ad6685419478c5aece46432f4bdd8d32c7345f1986496171e"}, + {file = "pydantic-1.10.7-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:c230c0d8a322276d6e7b88c3f7ce885f9ed16e0910354510e0bae84d54991143"}, + {file = "pydantic-1.10.7-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:976cae77ba6a49d80f461fd8bba183ff7ba79f44aa5cfa82f1346b5626542f8e"}, + {file = "pydantic-1.10.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7d45fc99d64af9aaf7e308054a0067fdcd87ffe974f2442312372dfa66e1001d"}, + {file = "pydantic-1.10.7-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d2a5ebb48958754d386195fe9e9c5106f11275867051bf017a8059410e9abf1f"}, + {file = "pydantic-1.10.7-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:abfb7d4a7cd5cc4e1d1887c43503a7c5dd608eadf8bc615413fc498d3e4645cd"}, + {file = "pydantic-1.10.7-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:80b1fab4deb08a8292d15e43a6edccdffa5377a36a4597bb545b93e79c5ff0a5"}, + {file = "pydantic-1.10.7-cp39-cp39-win_amd64.whl", hash = "sha256:d71e69699498b020ea198468e2480a2f1e7433e32a3a99760058c6520e2bea7e"}, + {file = "pydantic-1.10.7-py3-none-any.whl", hash = "sha256:0cd181f1d0b1d00e2b705f1bf1ac7799a2d938cce3376b8007df62b29be3c2c6"}, + {file = "pydantic-1.10.7.tar.gz", hash = "sha256:cfc83c0678b6ba51b0532bea66860617c4cd4251ecf76e9846fa5a9f3454e97e"}, ] [package.dependencies] @@ -2002,7 +2014,7 @@ files = [ ] [package.dependencies] -aiolimiter = {version = ">=1.0.0,<1.1.0", optional = true, markers = "extra == \"ext\""} +aiolimiter = {version = ">=1.0.0,<1.1.0", optional = true, markers = "extra == \"ext\" or extra == \"rate-limiter\""} APScheduler = {version = ">=3.10.0,<3.11.0", optional = true, markers = "extra == \"ext\""} cachetools = {version = ">=5.3.0,<5.4.0", optional = true, markers = "extra == \"ext\""} httpx = {version = ">=0.23.3,<0.24.0", extras = ["http2"]} @@ -2123,18 +2135,18 @@ test = ["coverage", "pytest"] [[package]] name = "redis" -version = "4.5.1" +version = "4.5.3" description = "Python client for Redis database and key-value store" category = "main" optional = false python-versions = ">=3.7" files = [ - {file = "redis-4.5.1-py3-none-any.whl", hash = "sha256:5deb072d26e67d2be1712603bfb7947ec3431fb0eec9c578994052e33035af6d"}, - {file = "redis-4.5.1.tar.gz", hash = "sha256:1eec3741cda408d3a5f84b78d089c8b8d895f21b3b050988351e925faf202864"}, + {file = "redis-4.5.3-py3-none-any.whl", hash = "sha256:7df17a0a2b72a4c8895b462dd07616c51b1dcb48fdd7ecb7b6f4bf39ecb2e94e"}, + {file = "redis-4.5.3.tar.gz", hash = "sha256:56732e156fe31801c4f43396bd3ca0c2a7f6f83d7936798531b9848d103381aa"}, ] [package.dependencies] -async-timeout = ">=4.0.2" +async-timeout = {version = ">=4.0.2", markers = "python_version < \"3.11\""} [package.extras] hiredis = ["hiredis (>=1.0.0)"] @@ -2348,7 +2360,7 @@ files = [ ] [package.dependencies] -greenlet = {version = "!=0.4.17", markers = "python_version >= \"3\" and (platform_machine == \"aarch64\" or platform_machine == \"ppc64le\" or platform_machine == \"x86_64\" or platform_machine == \"amd64\" or platform_machine == \"AMD64\" or platform_machine == \"win32\" or platform_machine == \"WIN32\")"} +greenlet = {version = "!=0.4.17", markers = "python_version >= \"3\" and platform_machine == \"aarch64\" or python_version >= \"3\" and platform_machine == \"ppc64le\" or python_version >= \"3\" and platform_machine == \"x86_64\" or python_version >= \"3\" and platform_machine == \"amd64\" or python_version >= \"3\" and platform_machine == \"AMD64\" or python_version >= \"3\" and platform_machine == \"win32\" or python_version >= \"3\" and platform_machine == \"WIN32\""} [package.extras] aiomysql = ["aiomysql", "greenlet (!=0.4.17)"] @@ -2583,14 +2595,14 @@ files = [ [[package]] name = "tzlocal" -version = "4.2" +version = "4.3" description = "tzinfo object for the local timezone" category = "main" optional = false -python-versions = ">=3.6" +python-versions = ">=3.7" files = [ - {file = "tzlocal-4.2-py3-none-any.whl", hash = "sha256:89885494684c929d9191c57aa27502afc87a579be5cdd3225c77c463ea043745"}, - {file = "tzlocal-4.2.tar.gz", hash = "sha256:ee5842fa3a795f023514ac2d801c4a81d1743bbe642e3940143326b3a00addd7"}, + {file = "tzlocal-4.3-py3-none-any.whl", hash = "sha256:b44c4388f3d34f25862cfbb387578a4d70fec417649da694a132f628a23367e2"}, + {file = "tzlocal-4.3.tar.gz", hash = "sha256:3f21d09e1b2aa9f2dacca12da240ca37de3ba5237a93addfd6d593afe9073355"}, ] [package.dependencies] @@ -2599,8 +2611,7 @@ pytz-deprecation-shim = "*" tzdata = {version = "*", markers = "platform_system == \"Windows\""} [package.extras] -devenv = ["black", "pyroma", "pytest-cov", "zest.releaser"] -test = ["pytest (>=4.3)", "pytest-mock (>=3.3)"] +devenv = ["black", "check-manifest", "flake8", "pyroma", "pytest (>=4.3)", "pytest-cov", "pytest-mock (>=3.3)", "zest.releaser"] [[package]] name = "ujson" @@ -2980,11 +2991,12 @@ docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)"] [extras] -all = ["pytest", "pytest-asyncio", "flaky", "Pyrogram", "TgCrypto"] +all = ["Pyrogram", "TgCrypto", "aiosqlite", "flaky", "pytest", "pytest-asyncio"] pyro = ["Pyrogram", "TgCrypto"] -test = ["pytest", "pytest-asyncio", "flaky"] +sqlite = ["aiosqlite"] +test = ["flaky", "pytest", "pytest-asyncio"] [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "893affc6c0dc0aa322078692592d9eb683fa9ffa689b9ac64ba1bdf4383abe22" +content-hash = "e52f9d32896f24e916c734b00eb75effa75933841ead1eb25c0408c9edea9f55" diff --git a/pyproject.toml b/pyproject.toml index 991c8cd0..2b4d0065 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,11 +43,13 @@ qrcode = "^7.4.2" cryptography = "^39.0.1" pillow = "^9.4.0" playwright = "^1.27.1" +aiosqlite = { extras = ["sqlite"], version = "^0.18.0" } [tool.poetry.extras] pyro = ["Pyrogram", "TgCrypto"] test = ["pytest", "pytest-asyncio", "flaky"] -all = ["pytest", "pytest-asyncio", "flaky", "Pyrogram", "TgCrypto"] +sqlite = ["aiosqlite"] +all = ["pytest", "pytest-asyncio", "flaky", "Pyrogram", "TgCrypto", "aiosqlite"] [build-system] requires = ["poetry-core"] diff --git a/requirements.txt b/requirements.txt index 6e30cb3e..acefb3d2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,7 @@ aiofiles==23.1.0 ; python_version >= "3.8" and python_version < "4.0" aiohttp==3.8.4 ; python_version >= "3.8" and python_version < "4.0" aiolimiter==1.0.0 ; python_version >= "3.8" and python_version < "4.0" aiosignal==1.3.1 ; python_version >= "3.8" and python_version < "4.0" +aiosqlite[sqlite]==0.18.0 ; python_version >= "3.8" and python_version < "4.0" alembic==1.10.2 ; python_version >= "3.8" and python_version < "4.0" anyio==3.6.2 ; python_version >= "3.8" and python_version < "4.0" appdirs==1.4.4 ; python_version >= "3.8" and python_version < "4.0" @@ -12,7 +13,7 @@ async-timeout==4.0.2 ; python_version >= "3.8" and python_version < "4.0" asyncmy==0.2.7 ; python_version >= "3.8" and python_version < "4.0" attrs==22.2.0 ; python_version >= "3.8" and python_version < "4.0" backports-zoneinfo==0.2.1 ; python_version >= "3.8" and python_version < "3.9" -beautifulsoup4==4.11.2 ; python_version >= "3.8" and python_version < "4.0" +beautifulsoup4==4.12.0 ; python_version >= "3.8" and python_version < "4.0" black==23.1.0 ; python_version >= "3.8" and python_version < "4.0" cachetools==5.3.0 ; python_version >= "3.8" and python_version < "4.0" certifi==2022.12.7 ; python_version >= "3.8" and python_version < "4.0" @@ -25,8 +26,8 @@ cryptography==39.0.2 ; python_version >= "3.8" and python_version < "4.0" enkanetwork-py @ git+https://github.com/mrwan200/EnkaNetwork.py@master ; python_version >= "3.8" and python_version < "4.0" et-xmlfile==1.1.0 ; python_version >= "3.8" and python_version < "4.0" exceptiongroup==1.1.1 ; python_version >= "3.8" and python_version < "3.11" -fakeredis==2.10.0 ; python_version >= "3.8" and python_version < "4.0" -fastapi==0.94.1 ; python_version >= "3.8" and python_version < "4.0" +fakeredis==2.10.2 ; python_version >= "3.8" and python_version < "4.0" +fastapi==0.95.0 ; python_version >= "3.8" and python_version < "4.0" flaky==3.7.0 ; python_version >= "3.8" and python_version < "4.0" frozenlist==1.3.3 ; python_version >= "3.8" and python_version < "4.0" genshin @ git+https://github.com/thesadru/genshin.py@master ; python_version >= "3.8" and python_version < "4.0" @@ -42,7 +43,7 @@ httpx==0.23.3 ; python_version >= "3.8" and python_version < "4.0" httpx[http2]==0.23.3 ; python_version >= "3.8" and python_version < "4.0" hyperframe==6.0.1 ; python_version >= "3.8" and python_version < "4.0" idna==3.4 ; python_version >= "3.8" and python_version < "4.0" -importlib-metadata==6.0.0 ; python_version >= "3.8" and python_version < "4.0" +importlib-metadata==6.1.0 ; python_version >= "3.8" and python_version < "4.0" importlib-resources==5.12.0 ; python_version >= "3.8" and python_version < "3.9" iniconfig==2.0.0 ; python_version >= "3.8" and python_version < "4.0" jinja2==3.1.2 ; python_version >= "3.8" and python_version < "4.0" @@ -55,21 +56,21 @@ multidict==6.0.4 ; python_version >= "3.8" and python_version < "4.0" mypy-extensions==1.0.0 ; python_version >= "3.8" and python_version < "4.0" openpyxl==3.1.2 ; python_version >= "3.8" and python_version < "4.0" packaging==23.0 ; python_version >= "3.8" and python_version < "4.0" -pathspec==0.11.0 ; python_version >= "3.8" and python_version < "4.0" +pathspec==0.11.1 ; python_version >= "3.8" and python_version < "4.0" pillow==9.4.0 ; python_version >= "3.8" and python_version < "4.0" platformdirs==3.1.1 ; python_version >= "3.8" and python_version < "4.0" playwright==1.27.1 ; python_version >= "3.8" and python_version < "4.0" pluggy==1.0.0 ; python_version >= "3.8" and python_version < "4.0" pyaes==1.6.1 ; python_version >= "3.8" and python_version < "4.0" pycparser==2.21 ; python_version >= "3.8" and python_version < "4.0" -pydantic==1.10.6 ; python_version >= "3.8" and python_version < "4.0" +pydantic==1.10.7 ; python_version >= "3.8" and python_version < "4.0" pyee==8.1.0 ; python_version >= "3.8" and python_version < "4.0" pygments==2.14.0 ; python_version >= "3.8" and python_version < "4.0" pypng==0.20220715.0 ; python_version >= "3.8" and python_version < "4.0" pyppeteer==1.0.2 ; python_version >= "3.8" and python_version < "4.0" pyrogram==2.0.102 ; python_version >= "3.8" and python_version < "4.0" pysocks==1.7.1 ; python_version >= "3.8" and python_version < "4.0" -pytest-asyncio==0.20.3 ; python_version >= "3.8" and python_version < "4.0" +pytest-asyncio==0.21.0 ; python_version >= "3.8" and python_version < "4.0" pytest==7.2.2 ; python_version >= "3.8" and python_version < "4.0" python-dotenv==1.0.0 ; python_version >= "3.8" and python_version < "4.0" python-telegram-bot[ext,rate-limiter]==20.1 ; python_version >= "3.8" and python_version < "4.0" @@ -77,10 +78,10 @@ pytz-deprecation-shim==0.1.0.post0 ; python_version >= "3.8" and python_version pytz==2022.7.1 ; python_version >= "3.8" and python_version < "4.0" pyyaml==6.0 ; python_version >= "3.8" and python_version < "4.0" qrcode==7.4.2 ; python_version >= "3.8" and python_version < "4.0" -redis==4.5.1 ; python_version >= "3.8" and python_version < "4.0" +redis==4.5.3 ; python_version >= "3.8" and python_version < "4.0" rfc3986[idna2008]==1.5.0 ; python_version >= "3.8" and python_version < "4.0" rich==13.3.2 ; python_version >= "3.8" and python_version < "4.0" -sentry-sdk==1.16.0 ; python_version >= "3.8" and python_version < "4.0" +sentry-sdk==1.17.0 ; python_version >= "3.8" and python_version < "4.0" setuptools==67.6.0 ; python_version >= "3.8" and python_version < "4.0" six==1.16.0 ; python_version >= "3.8" and python_version < "4.0" smmap==5.0.0 ; python_version >= "3.8" and python_version < "4.0" @@ -98,10 +99,10 @@ tornado==6.2 ; python_version >= "3.8" and python_version < "4.0" tqdm==4.65.0 ; python_version >= "3.8" and python_version < "4.0" typing-extensions==4.5.0 ; python_version >= "3.8" and python_version < "4.0" tzdata==2022.7 ; python_version >= "3.8" and python_version < "4.0" -tzlocal==4.2 ; python_version >= "3.8" and python_version < "4.0" +tzlocal==4.3 ; python_version >= "3.8" and python_version < "4.0" ujson==5.7.0 ; python_version >= "3.8" and python_version < "4.0" urllib3==1.26.15 ; python_version >= "3.8" and python_version < "4.0" -uvicorn[standard]==0.21.0 ; python_version >= "3.8" and python_version < "4.0" +uvicorn[standard]==0.21.1 ; python_version >= "3.8" and python_version < "4.0" uvloop==0.17.0 ; sys_platform != "win32" and sys_platform != "cygwin" and platform_python_implementation != "PyPy" and python_version >= "3.8" and python_version < "4.0" watchfiles==0.18.1 ; python_version >= "3.8" and python_version < "4.0" websockets==10.4 ; python_version >= "3.8" and python_version < "4.0" diff --git a/tests/integration/.env.example b/tests/integration/.env.example index ded9802f..01ff2fff 100644 --- a/tests/integration/.env.example +++ b/tests/integration/.env.example @@ -1,3 +1,4 @@ +DRIVER_NAME=mysql+asyncmy DB_PORT=3306 DB_USERNAME=root DB_PASSWORD=123456test diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index ee5f409b..b74fd401 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -4,7 +4,7 @@ import pytest import pytest_asyncio from core.config import config -from core.dependence.mysql import MySQL +from core.dependence.database import Database from core.dependence.redisdb import RedisDB @@ -18,8 +18,8 @@ def event_loop(): @pytest.fixture(scope="session") -def mysql(): - return MySQL.from_config(config=config) +def database(): + return Database.from_config(config=config) @pytest.fixture(scope="session") diff --git a/tests/integration/test_mysql.py b/tests/integration/test_database.py similarity index 71% rename from tests/integration/test_mysql.py rename to tests/integration/test_database.py index aabadeb9..e71a5b77 100644 --- a/tests/integration/test_mysql.py +++ b/tests/integration/test_database.py @@ -11,11 +11,11 @@ logger.info("%s", PlayersDataBase.__name__) # noinspection PyShadowingNames @pytest.mark.asyncio -async def test_mysql(mysql): - assert mysql +async def test_mysql(database): + assert database -async def test_init_create_all(mysql): - async with mysql.engine.begin() as conn: +async def test_init_create_all(database): + async with database.engine.begin() as conn: await conn.run_sync(SQLModel.metadata.drop_all) await conn.run_sync(SQLModel.metadata.create_all) diff --git a/tests/integration/test_player_service.py b/tests/integration/test_player_service.py index 931c178e..41b89c57 100644 --- a/tests/integration/test_player_service.py +++ b/tests/integration/test_player_service.py @@ -11,8 +11,8 @@ logger = logging.getLogger("TestPlayersService") @pytest_asyncio.fixture(scope="class", name="players_service") -def service(mysql): - repository = PlayersRepository(mysql) +def service(database): + repository = PlayersRepository(database) _players_service = PlayersService(repository) return _players_service