Skip to content

Commit

Permalink
♻️ use sqla url instead of yarl
Browse files Browse the repository at this point in the history
  • Loading branch information
yanyongyu authored Dec 2, 2023
1 parent 741760c commit 75f3407
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
22 changes: 10 additions & 12 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
@Author : yanyongyu
@Date : 2020-09-10 17:12:05
@LastEditors : yanyongyu
@LastEditTime : 2023-12-01 17:09:26
@LastEditTime : 2023-12-02 15:20:46
@Description : Entry File of the Bot
@GitHub : https://github.com/yanyongyu
"""
__author__ = "yanyongyu"

import nonebot
from yarl import URL
from sqlalchemy.engine.url import URL
from nonebot.adapters.qq import Adapter as QQAdapter
from nonebot.adapters.github import Adapter as GitHubAdapter
from nonebot.adapters.onebot.v11 import Adapter as ONEBOT_V11_Adapter
Expand All @@ -24,16 +24,14 @@
driver.register_adapter(ONEBOT_V11_Adapter)

config = driver.config
config.sqlalchemy_database_url = str(
URL.build(
scheme="postgresql+asyncpg",
user=config.postgres_user,
password=config.postgres_password,
host=config.postgres_host,
port=config.postgres_port,
path=f"/{config.postgres_db}",
)
)
config.sqlalchemy_database_url = URL.create(
"postgresql+asyncpg",
username=config.postgres_user,
password=config.postgres_password,
host=config.postgres_host,
port=config.postgres_port,
database=config.postgres_db,
).render_as_string()

nonebot.load_plugins("src/providers")
nonebot.load_all_plugins(set(config.plugins), {"src/plugins"}.union(config.plugin_dirs))
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ license = "MIT"

[tool.poetry.dependencies]
python = "^3.11"
yarl = "^1.9.3"
# pin anyio v3 due to fastapi incompatibility
anyio = "^3.7.1"
psutil = "^5.7.2"
Expand Down

0 comments on commit 75f3407

Please sign in to comment.