nonebot-plugin-navicat


Namenonebot-plugin-navicat JSON
Version 0.3.0 PyPI version JSON
download
home_pagehttps://github.com/synodriver/nonebot_plugin_navicat
SummaryA batabase manager plugin for nonebot2,provide capability of connection to all kinds of databases
upload_time2023-06-25 08:55:46
maintainer
docs_urlNone
authorsynodriver
requires_python>=3.7
licenseGPLv3
keywords nonebot
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # nonebot_plugin_navicat
[![pypi](https://img.shields.io/pypi/v/nonebot-plugin-navicat.svg)](https://pypi.org/project/nonebot_plugin_navicat/) 
![implementation](https://img.shields.io/pypi/implementation/nonebot-plugin-navicat)
![wheel](https://img.shields.io/pypi/wheel/nonebot-plugin-navicat)
![python](https://img.shields.io/pypi/pyversions/nonebot-plugin-navicat)
[![license](https://img.shields.io/github/license/synodriver/nonebot_plugin_navicat.svg)](https://raw.githubusercontent.com/synodriver/nonebot_plugin_navicat/main/LICENSE)

- 基于[nonebot2](https://github.com/nonebot/nonebot2)

## 功能

- 对外暴露出数据库连接 支持mysql mongodb redis

## 开始使用

必须使用 pip

- 通过 pip 从 [PyPI](https://pypi.org/project/nonebot_plugin_navicat/) 安装

``` {.sourceCode .bash}
pip install nonebot-plugin-navicat
```
- 我全都要
``` {.sourceCode .bash}
pip install nonebot-plugin-navicat[all]
```
- 要使用mysql
``` {.sourceCode .bash}
pip install nonebot-plugin-navicat[mysql]
```
- 要使用postgresql
``` {.sourceCode .bash}
pip install nonebot-plugin-navicat[postgresql]
```
- 要使用sqlite
``` {.sourceCode .bash}
pip install nonebot-plugin-navicat[sqlite]
```
- 要使用mongodb
``` {.sourceCode .bash}
pip install nonebot-plugin-navicat[mongodb]
```
- 要使用redis
``` {.sourceCode .bash}
pip install nonebot-plugin-navicat[redis]
```
- 要使用elasticsearch
``` {.sourceCode .bash}
pip install nonebot-plugin-navicat[elasticsearch]
```

- 在 nonebot2 项目中设置 load_plugin()

``` {.sourceCode .python}
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=


# 以后会加入更多数据库支持
```
## 导出给其他插件

```{.sourceCode .python}
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](https://github.com/encode/databases/) 代替直接连接,有了广泛的通用性
- 移除了直接命令行查询数据库的功能,迁移到了单独的一个插件里面 *[nonebot-plugin-super](https://github.com/synodriver/nonebot_plugin_super)*
## 特别感谢

- [Mrs4s / go-cqhttp](https://github.com/Mrs4s/go-cqhttp)
- [nonebot / nonebot2](https://github.com/nonebot/nonebot2)

## 优化建议

- bug report
- more databases support
![](https://i.pixiv.cat/img-original/img/2018/08/29/00/16/10/70434240_p0.png "bug哪里跑 看姐姐给你们全抓起来~")

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/synodriver/nonebot_plugin_navicat",
    "name": "nonebot-plugin-navicat",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "nonebot",
    "author": "synodriver",
    "author_email": "diguohuangjiajinweijun@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/54/dd/6cf532716427e4797a71fca9863e2eb1cd73062dd51a42a8d495faade681/nonebot-plugin-navicat-0.3.0.tar.gz",
    "platform": null,
    "description": "# nonebot_plugin_navicat\n[![pypi](https://img.shields.io/pypi/v/nonebot-plugin-navicat.svg)](https://pypi.org/project/nonebot_plugin_navicat/) \n![implementation](https://img.shields.io/pypi/implementation/nonebot-plugin-navicat)\n![wheel](https://img.shields.io/pypi/wheel/nonebot-plugin-navicat)\n![python](https://img.shields.io/pypi/pyversions/nonebot-plugin-navicat)\n[![license](https://img.shields.io/github/license/synodriver/nonebot_plugin_navicat.svg)](https://raw.githubusercontent.com/synodriver/nonebot_plugin_navicat/main/LICENSE)\n\n- \u57fa\u4e8e[nonebot2](https://github.com/nonebot/nonebot2)\n\n## \u529f\u80fd\n\n- \u5bf9\u5916\u66b4\u9732\u51fa\u6570\u636e\u5e93\u8fde\u63a5 \u652f\u6301mysql mongodb redis\n\n## \u5f00\u59cb\u4f7f\u7528\n\n\u5fc5\u987b\u4f7f\u7528 pip\n\n- \u901a\u8fc7 pip \u4ece [PyPI](https://pypi.org/project/nonebot_plugin_navicat/) \u5b89\u88c5\n\n``` {.sourceCode .bash}\npip install nonebot-plugin-navicat\n```\n- \u6211\u5168\u90fd\u8981\n``` {.sourceCode .bash}\npip install nonebot-plugin-navicat[all]\n```\n- \u8981\u4f7f\u7528mysql\n``` {.sourceCode .bash}\npip install nonebot-plugin-navicat[mysql]\n```\n- \u8981\u4f7f\u7528postgresql\n``` {.sourceCode .bash}\npip install nonebot-plugin-navicat[postgresql]\n```\n- \u8981\u4f7f\u7528sqlite\n``` {.sourceCode .bash}\npip install nonebot-plugin-navicat[sqlite]\n```\n- \u8981\u4f7f\u7528mongodb\n``` {.sourceCode .bash}\npip install nonebot-plugin-navicat[mongodb]\n```\n- \u8981\u4f7f\u7528redis\n``` {.sourceCode .bash}\npip install nonebot-plugin-navicat[redis]\n```\n- \u8981\u4f7f\u7528elasticsearch\n``` {.sourceCode .bash}\npip install nonebot-plugin-navicat[elasticsearch]\n```\n\n- \u5728 nonebot2 \u9879\u76ee\u4e2d\u8bbe\u7f6e load_plugin()\n\n``` {.sourceCode .python}\nnonebot.load_plugin('nonebot_plugin_navicat')\n```\n\n- \u53c2\u7167\u4e0b\u6587\u5728 nonebot2 \u9879\u76ee\u7684\u73af\u5883\u6587\u4ef6 .env.\\* \u4e2d\u6dfb\u52a0\u914d\u7f6e\u9879\n\n## \u914d\u7f6e\u9879\n\u914d\u7f6e\u6570\u636e\u5e93\u8fde\u63a5\n```\n# mysql \u5982\u679c\u6709MYSQL_HOST\u5219\u8868\u793a\u8981\u8fdb\u884cmysql\u8fde\u63a5\nMYSQL_HOST=\nMYSQL_PORT=\nMYSQL_USER=\nMYSQL_PASSWORD=\nMYSQL_DB=\n\n# postgresql \u5982\u679c\u6709PGSQL_HOST\u5219\u8868\u793a\u8981\u8fdb\u884cpostgresql\u8fde\u63a5\nPGSQL_HOST=\nPGSQL_PORT=\nPGSQL_USER=\nPGSQL_PASSWORD=\nPGSQL_DB=\n\n# sqlite \u5982\u679c\u6709SQLITE_HOST\u5219\u8868\u793a\u8981\u8fdb\u884csqlite\u8fde\u63a5 \u8fd9\u91cc\u662f\u8def\u5f84\nSQLITE_HOST=\n\n# mongodb \u5982\u679c\u6709MONGODB_HOST\u5219\u8868\u793a\u8981\u8fdb\u884cmongodb\u8fde\u63a5\nMONGODB_HOST=\nMONGODB_PORT=\nMONGODB_USER=\nMONGODB_PASSWORD=\n\n# redis \u5982\u679c\u6709REDIS_HOST\u5219\u8868\u793a\u8981\u8fdb\u884credis\u8fde\u63a5\nREDIS_PARAMS={\"decode_responses\":true}\nREDIS_HOST=\nREDIS_PORT=\nREDIS_PASSWORD=\nREDIS_DB=\n\n# redis sentinel \u5982\u679c\u6709REDIS_SENTINEL_PARAMS\u5219\u8868\u793a\u8981\u8fdb\u884credis sentinel\u8fde\u63a5\nREDIS_SENTINEL_PARAMS=\nREDIS_SENTINEL_SERVICE_NAME=    # \u5fc5\u586b\n\n# redis cluster \u5982\u679c\u6709REDIS_CLUSTER_PARAMS\u5219\u8868\u793a\u8981\u8fdb\u884credis cluster\u8fde\u63a5\nREDIS_CLUSTER_PARAMS=\nREDIS_CLUSTER_NODES=\n# \u96c6\u7fa4\u6ca1\u6709db\u9009\u9879\n\n# elasticsearch \u5982\u679c\u6709ELASTICSEARCH_PARAMS\u5219\u8868\u793a\u8981\u8fdb\u884celasticsearch\u8fde\u63a5\nELASTICSEARCH_PARAMS=\nELASTICSEARCH_HOSTS=\n\n\n# \u4ee5\u540e\u4f1a\u52a0\u5165\u66f4\u591a\u6570\u636e\u5e93\u652f\u6301\n```\n## \u5bfc\u51fa\u7ed9\u5176\u4ed6\u63d2\u4ef6\n\n```{.sourceCode .python}\nfrom nonebot import require\n\nrequire(\"nonebot_plugin_navicat\")\nimport nonebot_plugin_navicat as export # \u517c\u5bb9\u8001\u5199\u6cd5\uff0c\u4e0d\u81f3\u4e8e\u5927\u6539\n\nexport.mysql_pool # mysql\u7684\n\nexport.pgsql_pool # postgresql\u7684\n\nexport.sqlite_pool # sqlite\u7684\n\nexport.mongodb_client # mongodb\u7684\n\nexport.redis_client # redis\u7684\nexport.redis_sentinel\nexport.redis_cluster\n\nexport.elasticsearch # elasticsearch\u7684\n```\n\n## \u76f4\u63a5\u67e5\u8be2\u6570\u636e\u5e93 (0.2.0\u4e2d\u5df2\u5220\u9664)\n- \u5371\u9669\u529f\u80fd! \u5728\u914d\u7f6e\u4e2d\u542f\u7528```NAVICAT_EXECUTE_SQL=true```\u6765\u5f00\u542f\n- \u4f7f\u7528\u65b9\u6cd5:\u53d1\u9001```super ${dbname} + sql```\u6765\u67e5\u8be2\n```\nsuper mysql\nshow databases\n```\n## \u66f4\u65b0\u8bb0\u5f55\n- v0.3.0rc1 \u9002\u914dnonebot rc\u7248\u672c\n\n- v0.2.3 \u4fee\u590dbeta2\u7684bug\n\n\n- v0.2.1 \u52a0\u5165\u4e86\u5bf9redis\u54e8\u5175\u548c\u96c6\u7fa4\u7684\u652f\u6301\uff0c\u5bf9```elasticsearch```\u7684\u652f\u6301\n\n\n\n- v0.2.0 \u4f7f\u7528 [databases](https://github.com/encode/databases/) \u4ee3\u66ff\u76f4\u63a5\u8fde\u63a5,\u6709\u4e86\u5e7f\u6cdb\u7684\u901a\u7528\u6027\n- \u79fb\u9664\u4e86\u76f4\u63a5\u547d\u4ee4\u884c\u67e5\u8be2\u6570\u636e\u5e93\u7684\u529f\u80fd,\u8fc1\u79fb\u5230\u4e86\u5355\u72ec\u7684\u4e00\u4e2a\u63d2\u4ef6\u91cc\u9762 *[nonebot-plugin-super](https://github.com/synodriver/nonebot_plugin_super)*\n## \u7279\u522b\u611f\u8c22\n\n- [Mrs4s / go-cqhttp](https://github.com/Mrs4s/go-cqhttp)\n- [nonebot / nonebot2](https://github.com/nonebot/nonebot2)\n\n## \u4f18\u5316\u5efa\u8bae\n\n- bug report\n- more databases support\n![](https://i.pixiv.cat/img-original/img/2018/08/29/00/16/10/70434240_p0.png \"bug\u54ea\u91cc\u8dd1 \u770b\u59d0\u59d0\u7ed9\u4f60\u4eec\u5168\u6293\u8d77\u6765~\")\n",
    "bugtrack_url": null,
    "license": "GPLv3",
    "summary": "A batabase manager plugin for nonebot2,provide capability of connection to all kinds of databases",
    "version": "0.3.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/synodriver/nonebot_plugin_navicat/issues",
        "Homepage": "https://github.com/synodriver/nonebot_plugin_navicat"
    },
    "split_keywords": [
        "nonebot"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0651319127d0ec37d5d05263b4d2d870ca5543cd6b6d3ff1311bebfeb72a866b",
                "md5": "5abb8a29309ab2de29fb2b2640903007",
                "sha256": "9c282d4b5d1b2163298a7166147337649e14c62d3a427653090c2ddc490abb7d"
            },
            "downloads": -1,
            "filename": "nonebot_plugin_navicat-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5abb8a29309ab2de29fb2b2640903007",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 21211,
            "upload_time": "2023-06-25T08:55:44",
            "upload_time_iso_8601": "2023-06-25T08:55:44.847476Z",
            "url": "https://files.pythonhosted.org/packages/06/51/319127d0ec37d5d05263b4d2d870ca5543cd6b6d3ff1311bebfeb72a866b/nonebot_plugin_navicat-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "54dd6cf532716427e4797a71fca9863e2eb1cd73062dd51a42a8d495faade681",
                "md5": "27701be9c196a34553618c0e153baddb",
                "sha256": "e7c41c9273e78fc0a63f38021a3c453bc7b821c09638f11a0c26e016c09354d4"
            },
            "downloads": -1,
            "filename": "nonebot-plugin-navicat-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "27701be9c196a34553618c0e153baddb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 21009,
            "upload_time": "2023-06-25T08:55:46",
            "upload_time_iso_8601": "2023-06-25T08:55:46.408678Z",
            "url": "https://files.pythonhosted.org/packages/54/dd/6cf532716427e4797a71fca9863e2eb1cd73062dd51a42a8d495faade681/nonebot-plugin-navicat-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-25 08:55:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "synodriver",
    "github_project": "nonebot_plugin_navicat",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "nonebot-plugin-navicat"
}
        
Elapsed time: 0.10387s