Skip to main content

MySQL Shell Python client

CI/CD Status Coverage Status Apache license

MySQL Shell is an advanced client for MySQL Server that allow system administrator to perform both cluster and instance level operations, using a single binary.

This project provides a Python client to perform the most common set of operations, in addition to a set of predefined queries to cover most of the common use-cases.

🧑‍💻 Usage

  1. Install MySQL Shell.

  2. Install the package from PyPi:

    pip install mysql-shell-client
    
  3. Import and build the executors:

    from mysql_shell.executors import LocalExecutor
    from mysql_shell.models import ConnectionDetails
    
    cluster_conn = ConnectionDetails(
        username="...",
        password="...",
        host="...",
        port="...",
    )
    instance_conn = ConnectionDetails(
        username="...",
        password="...",
        host="...",
        port="...",
    )
    
    cluster_executor = LocalExecutor(cluster_conn, "mysqlsh")
    instance_executor = LocalExecutor(instance_conn, "mysqlsh")
    
  4. Import and build the clients:

    from mysql_shell.builders.quoting import ArgsQuoter, QueryQuoter
    from mysql_shell.clients import ClusterClient, InstanceClient
    
    args_quoter = ArgsQuoter()
    query_quoter = QueryQuoter()
    
    cluster_client = ClusterClient(cluster_executor, args_quoter)
    instance_client = InstanceClient(instance_executor, query_quoter)
    

🔧 Development

Dependencies

In order to install all the required packages:

poetry install --all-extras

Linting

All Python files are linted using Ruff, to run it:

tox -e lint

Testing

Project testing is performed using Pytest, to run them:

tox -e unit
export MYSQL_DATABASE="test"
export MYSQL_USERNAME="root"
export MYSQL_PASSWORD="root_pass"
export MYSQL_SHELL_PATH="mysqlsh"

sudo --preserve-env docker compose -f compose/mysql-8.0.yaml up --wait && tox -e integration
sudo --preserve-env docker compose -f compose/mysql-8.0.yaml down

Release

Commits can be tagged to create releases of the package, in order to do so:

  1. Bump up the version within the pyproject.toml file.
  2. Add a new section to the CHANGELOG.md.
  3. Commit + push the changes.
  4. Trigger the release workflow.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mysql_shell_client-1.1.1.tar.gz (20.6 kB view details)

Uploaded Source

Built Distribution

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

mysql_shell_client-1.1.1-py3-none-any.whl (30.3 kB view details)

Uploaded Python 3

File details

Details for the file mysql_shell_client-1.1.1.tar.gz.

File metadata

  • Download URL: mysql_shell_client-1.1.1.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mysql_shell_client-1.1.1.tar.gz
Algorithm Hash digest
SHA256 b562df2c7cff2ebc3585c1098f8a729f0dfd6a4d09375f2648535f724544007c
MD5 adb4ba2406ca5cc497e1bc154770e40a
BLAKE2b-256 f52acdf20a8f6b5a2210d15a256f97c7c694ff65e7cecb34d5ebaaa6793fd6cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for mysql_shell_client-1.1.1.tar.gz:

Publisher: release.yaml on canonical/mysql-shell-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mysql_shell_client-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mysql_shell_client-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7da5f54f34aa9e3573aae8ef8f5971d8eb64d252fad4dd279fb9bd6b4e26063c
MD5 0f7c966fecb06d73d749a6cb916cfe99
BLAKE2b-256 15e11eaa7ebe6e90de68d1dc45809f9c5d2e101cb0b8b52c3289c0a636d4c9a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for mysql_shell_client-1.1.1-py3-none-any.whl:

Publisher: release.yaml on canonical/mysql-shell-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 files

1.1.0

2 files

1.0.0

2 files

0.9.0

2 files

0.8.1

2 files

0.8.0

2 files

0.7.1

2 files

0.7.0

2 files

0.6.1

2 files

0.6.0

2 files

0.5.1

2 files

0.5.0

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

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