编写MySQL Shell插件(REPORT)
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了编写MySQL Shell插件(REPORT),小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2883字,纯文字阅读大概需要5分钟。
内容图文
![编写MySQL Shell插件(REPORT)](/upload/InfoBanner/zyjiaocheng/863/237e6c6475b64014a8ca2ee8da5e3904.jpg)
作者:马楚成 (Ivan Ma)
编译:徐轶韬
MySQL Shell is a powerful tool. It allows Javascript, Python and SQL access to MySQL.
MySQL Shell是一个功能强大的工具。它允许Javascript,Python和SQL访问MySQL。
Usage of MySQL Shell can be
- As admin tool to MySQL Server
- As Scripting Engine to run Javascript or Python or SQL to access MySQL Server
- As a tools to allow Document Store access (like collection API) with MySQL Server
- As MySQL InnoDB Cluster admin Tooling
可以使用MySQL Shell。
1.作为MySQL Server的管理工具。
2.作为运行Javascript或Python或SQL的脚本引擎,以访问MySQL Server。
3.作为允许通过MySQL Server访问文档存储(如集合API)的工具。
4.作为MySQL InnoDB Cluster管理工具。
Customization and extensible framework is essential to a tool as such DB administrators can create customized report and extension to do the daily job.
自定义和可扩展框架对于工具至关重要,数据库管理员可以创建自定义的报告和扩展来执行日常工作。
This tutorial is written to provide a short summary how we can create a MySQL Shell Report in Python.
编写本教程的目的是提供一个简短摘要,介绍如何使用Python创建MySQL Shell报告。
What is MySQL Shell Report
MySQL Shell report can be executed thru "\show"
什么是MySQL Shell报表
MySQL Shell报表可以通过“ \ show”执行
There are 3 'report's coming with MySQL Shell - namely 'query', 'thread', 'threads'.
MySQL Shell附带3个“报告”,即'query', 'thread', 'threads'。
Query Report :
Getting the "help" with a report can simply to run "\show query --help"
查询报告:
获取报告“帮助”可以简单地运行“ \ show query --help”
Running a Report with a connected session as such the query is executed and printed on the screen (e.g. Running "SELECT 1" query)
通过连接的会话运行报告,这样查询将被执行并打印在屏幕上(例如,运行“ SELECT 1”查询)
Creating a New Report in Python - DB Size
使用Python创建新报告-数据库大小
MySQL Shell allows customization based on the $HOME/.mysqlsh/plugins/ folder
MySQL Shell允许基于$ HOME / .mysqlsh / plugins /folder进行自定义
When MySQL Shell is launched, it looks for all initialization script (init.py / init.js) within the "plugins" folder.
启动MySQL Shell时,它将在“ plugins”中查找所有初始化脚本(init.py / init.js)。”文件夹。
File : $HOME/.mysqlsh/plugins/ext/dbutil/init.py
Once the file is created under the $HOME/.mysqlsh/plugins/ext/dbutil/init.py, MySQL Shell looks up NEW report and the "\show" shows the added "dbsize" report.
在$ HOME / .mysqlsh / plugins / ext / dbutil / init.py下创建文件后,MySQL Shell将查找新报告,而“ \ show”将显示添加的“ dbsize”报告。
With a CONNECTED session, and Running the report can be simply to execute "\show dbsize"
使用CONNECTED会话,然后运行报告,可以简单地执行“ \ show dbsize”。
There is OPTION "limit" which we put into the Python init.py. To show only 3 lines, we can add option (-l 3) as shown as follows.
我们在Python init.py中放入了OPTION“ limit”。仅显示3行,可以如下所示添加选项(-l 3)。
Enjoy Reading!
内容总结
以上是互联网集市为您收集整理的编写MySQL Shell插件(REPORT)全部内容,希望文章能够帮你解决编写MySQL Shell插件(REPORT)所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。