nonebot_plugin_navicat
- 基于nonebot2
功能
- 对外暴露出数据库连接 支持mysql mongodb redis
开始使用
必须使用 pip
- 通过 pip 从 PyPI 安装
pip install nonebot-plugin-navicat
- 我全都要
pip install nonebot-plugin-navicat[all]
- 要使用mysql
pip install nonebot-plugin-navicat[mysql]
- 要使用postgresql
pip install nonebot-plugin-navicat[postgresql]
- 要使用sqlite
pip install nonebot-plugin-navicat[sqlite]
- 要使用mongodb
pip install nonebot-plugin-navicat[mongodb]
- 要使用redis
pip install nonebot-plugin-navicat[redis]
- 要使用elasticsearch
pip install nonebot-plugin-navicat[elasticsearch]
- 在 nonebot2 项目中设置 load_plugin()
nonebot.load_plugin('nonebot_plugin_navicat')
- 参照下文在 nonebot2 项目的环境文件 .env.* 中添加配置项
配置项
配置数据库连接
# mysql 如果有MYSQL_HOST则表示要进行mysql连接
MYSQL_HOST=
MYSQL_PORT=
MYSQL_USER=
MYSQL_PASSWORD=
MYSQL_DB=
# postgresql 如果有PGSQL_HOST则表示要进行postgresql连接
PGSQL_HOST=
PGSQL_PORT=
PGSQL_USER=
PGSQL_PASSWORD=
PGSQL_DB=
# sqlite 如果有SQLITE_HOST则表示要进行sqlite连接 这里是路径
SQLITE_HOST=
# mongodb 如果有MONGODB_HOST则表示要进行mongodb连接
MONGODB_HOST=
MONGODB_PORT=
MONGODB_USER=
MONGODB_PASSWORD=
# redis 如果有REDIS_HOST则表示要进行redis连接
REDIS_PARAMS={"decode_responses":true}
REDIS_HOST=
REDIS_PORT=
REDIS_PASSWORD=
REDIS_DB=
# redis sentinel 如果有REDIS_SENTINEL_PARAMS则表示要进行redis sentinel连接
REDIS_SENTINEL_PARAMS=
REDIS_SENTINEL_SERVICE_NAME= # 必填
# redis cluster 如果有REDIS_CLUSTER_PARAMS则表示要进行redis cluster连接
REDIS_CLUSTER_PARAMS=
REDIS_CLUSTER_NODES=
# 集群没有db选项
# elasticsearch 如果有ELASTICSEARCH_PARAMS则表示要进行elasticsearch连接
ELASTICSEARCH_PARAMS=
ELASTICSEARCH_HOSTS=
# 以后会加入更多数据库支持
导出给其他插件
from nonebot import require
require("nonebot_plugin_navicat")
import nonebot_plugin_navicat as export # 兼容老写法,不至于大改
export.mysql_pool # mysql的
export.pgsql_pool # postgresql的
export.sqlite_pool # sqlite的
export.mongodb_client # mongodb的
export.redis_client # redis的
export.redis_sentinel
export.redis_cluster
export.elasticsearch # elasticsearch的
直接查询数据库 (0.2.0中已删除)
- 危险功能! 在配置中启用
NAVICAT_EXECUTE_SQL=true来开启 - 使用方法:发送
super ${dbname} + sql来查询
super mysql
show databases
更新记录
-
v0.3.0rc1 适配nonebot rc版本
-
v0.2.3 修复beta2的bug
-
v0.2.1 加入了对redis哨兵和集群的支持,对
elasticsearch的支持 -
v0.2.0 使用 databases 代替直接连接,有了广泛的通用性
-
移除了直接命令行查询数据库的功能,迁移到了单独的一个插件里面 nonebot-plugin-super
特别感谢
优化建议
- bug report
- more databases support
Metadata
Release files for nonebot-plugin-navicat 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nonebot-plugin-navicat-0.4.0.tar.gz | 21.1 kB | Without provenance | Details for nonebot-plugin-navicat-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nonebot_plugin_navicat-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for nonebot_plugin_navicat-0.4.0-py3-none-any.whl |
Total release size: 42.3 kB
Security for nonebot-plugin-navicat 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.