Skip to main content

适用于 Nonebot2 的数据存储插件

Project description

nonebot

NoneBot Plugin DataStore

✨ NoneBot 数据存储插件 ✨

license pypi python

使用方式

加载插件后直接导入

# 先声明依赖
from nonebot import require
require("nonebot_plugin_datastore")
# 接着直接导入
from nonebot.params import Depends
from nonebot_plugin_datastore import PluginData, get_session
from sqlmodel.ext.asyncio.session import AsyncSession

DATA = PluginData("plugin_name")

@matcher.handle()
def handle(session: AsyncSession = Depends(get_session)):
    await session.exec()

配置项

配置方式:直接在 NoneBot 全局配置文件中添加以下配置项即可。

datastore_cache_dir

datastore_config_dir

datastore_data_dir

datastore_enable_database

  • 类型: bool
  • 默认: True
  • 说明: 是否启动数据库

datastore_database_url

  • 类型: str
  • 默认: sqlite+aiosqlite:///data_dir/data.db
  • 说明: 数据库连接字符串,默认使用 SQLite 数据库

datastore_database_echo

  • 类型: bool
  • 默认: False
  • 说明: 是否显示数据库执行的语句与其参数列表

计划

  • 调整配置为 K-V 存储
  • 调整配置存放位置至专门的配置目录
  • 数据库为可选项
  • 支持将配置存放至数据库中
  • 支持 Alembic

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nonebot-plugin-datastore-0.3.1.tar.gz (6.6 kB view hashes)

Uploaded Source

Built Distribution

nonebot_plugin_datastore-0.3.1-py3-none-any.whl (7.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page