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.2.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nonebot_plugin_datastore-0.3.2-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file nonebot-plugin-datastore-0.3.2.tar.gz.

File metadata

File hashes

Hashes for nonebot-plugin-datastore-0.3.2.tar.gz
Algorithm Hash digest
SHA256 7d31320f1919062b4b56dc98faf10dbb0ad786d5902de62f448af6e4d5e8fe4e
MD5 8322438d851dea287df1cc3d181cc92f
BLAKE2b-256 0e4285065be7812f8acfa3cc113335d19d317a3f59cc177481311fcdbd078d23

See more details on using hashes here.

File details

Details for the file nonebot_plugin_datastore-0.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_datastore-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bbe42405000f7c38fdd2c9f0c881b15a33d5f0a66b8b18c6174526e1c1edbd2f
MD5 302feca4346c78a52b034ef9ccf373f5
BLAKE2b-256 226fd995f7356f05dd2169f00ef29bcfe43df0468239c68359276d501f51b7bd

See more details on using hashes here.

Supported by

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