Git Product home page Git Product logo

mysqlshell-plugins's Introduction

mysql-shell-ex

A collection of MySQL Shell example plugins (MySQL Shell >= 8.0.22).

After installing this plugin collection into the .mysqlsh/plugins/ folder, all the plugins will be automatically loaded at MySQL Shell startup.

To get help about the individual plugins type \? <plugin>.

MySQL JS> \? schema_utils
NAME
      schema_utils - Schema management and utilities.

DESCRIPTION
      A collection of schema management tools and related utilities that work
      on schemas."

FUNCTIONS
      deleteProcedures([schema][, routine][, session])
            Delete stored procedures.

      help([member])
            Provides help about this object and it's members

      showDefaults(table[, schema][, session])
            Lists the default values of each column in a table.

      showInvalidDates([table][, schema][, session])
            Show Invalid Dates

      showProcedures([schema][, session])
            Lists all stored procedures of either all schemas or a given
            schema.

      showRoutines([schema][, session])
            Show Routines.


MySQL JS> schema_utils.showProcedures()
+----------------+-------------------------------------+
| ROUTINE_SCHEMA | ROUTINE_NAME                        |
+----------------+-------------------------------------+
| sys            | extract_schema_from_file_name       |
| sys            | extract_table_from_file_name        |
...

MySQL JS> \py
Switching to Python mode...

MySQL PY> schema_utils.show_procedures()
+----------------+-------------------------------------+
| ROUTINE_SCHEMA | ROUTINE_NAME                        |
+----------------+-------------------------------------+
| sys            | extract_schema_from_file_name       |
| sys            | extract_table_from_file_name        |
...

Installation

To install this demo on your machine type the following commands after you have installed the MySQL Shell and the git command line tools.

This will clone the repository and copy the files to the right path in order to be automatically loaded on MySQL Shell startup.

macOS / Linux

$ mkdir -p ~/.mysqlsh/plugins
$ git clone https://github.com/lefred/mysqlshell-plugins.git ~/.mysqlsh/plugins

Windows

$ mkdir %AppData%\MySQL\mysqlsh\plugins
$ git clone https://github.com/lefred/mysqlshell-plugins.git %AppData%\MySQL\mysqlsh\plugins

Dependencies

$ sudo mysqlsh --pym pip install -r requirements.txt
$ mysqlsh --pym pip install --user -r requirements.txt

Missing Modules

It might be possible that for some plugins, your are missing some modules. Usually it is python3-requests.

You can then just install it. However, on some systems, the version of Python 3 doesn't match the version linked with MySQL Shell. This is the case with OL7/OL8 where Python 3.6 is installed and MySQL Shell Enterprise build provides Python 3.7.

If this is the case for you, you can install the missing modules within MySQL Shell too using mysqlsh --pym pip.

Example with requests:

For the router and proxySQL plugin, requests is required, if you don't have it installed, when you start MySQL Shell, you will get this message:

Error importing module 'requests', check if it's installed (Python 3.7.7)

You have 2 options, install it system wide (available for all users), if you have root access, or just for your user:

$ sudo mysqlsh --pym pip install requests

or

$ mysqlsh --pym pip install --user requests

That's it !

Extending the MySQL Shell

Please take a look at the demo/init.py file to learn how to extend the MySQL Shell with plugins.

mysqlshell-plugins's People

Contributors

lefred avatar amiasli avatar miguelaraujo avatar berntm avatar ivanxma avatar gdsotirov avatar markusalbe avatar v0112358 avatar yoshiakiyamasaki avatar thecicco avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.