Skip to main content

Python client for MySQL Shell

Project description

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 the package from PyPi:

    pip install mysql-shell-client
    
  2. 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")
    
  3. Import and build the query builders [optional]:

    from mysql_shell.builders import CharmLockingQueryBuilder
    
    # This is just an example
    builder = CharmLockingQueryBuilder("mysql", "locking")
    query = builder.build_table_creation_query()
    rows = instance_executor.execute_sql(query)
    
  4. Import and build the clients:

    from mysql_shell.clients import MySQLClusterClient, MySQLInstanceClient
    
    cluster_client = MySQLClusterClient(cluster_executor)
    instance_client = MySQLInstanceClient(instance_executor)
    

🔧 Development

Dependencies

In order to install all the development 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"

podman-compose -f compose/mysql-8.0.yaml up --detach && tox -e integration
podman-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.

Project details


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-0.4.1.tar.gz (17.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-0.4.1-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mysql_shell_client-0.4.1.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mysql_shell_client-0.4.1.tar.gz
Algorithm Hash digest
SHA256 423c09103e2fd3d52e2ac7d35d0ed857d10ec869afdb42efa5a79867d7492cc4
MD5 94084703728572de7e50ee1479adf195
BLAKE2b-256 0851f42c66aa31b0aad4f20d0845bd2ea000d4d9330019574b3063bc12ee8720

See more details on using hashes here.

Provenance

The following attestation bundles were made for mysql_shell_client-0.4.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-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mysql_shell_client-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8b8dd89fd1e9cad42e0e98029af7711b0d3a6eacda1b70c6beab94adaf5d870d
MD5 380cda96a4d6e6d30f7a1b9471a11742
BLAKE2b-256 2f145489827ab46a83d88094f091d399bf0e5b9f579b57c9f24dce7661818c4e

See more details on using hashes here.

Provenance

The following attestation bundles were made for mysql_shell_client-0.4.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.

Supported by

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