Python client for MySQL Shell
Project description
MySQL Shell Python client
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
-
Install the package from PyPi:
pip install mysql-shell-client
-
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")
-
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)
-
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:
- Bump up the version within the
pyproject.tomlfile. - Add a new section to the
CHANGELOG.md. - Commit + push the changes.
- Trigger the release workflow.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mysql_shell_client-0.3.0.tar.gz.
File metadata
- Download URL: mysql_shell_client-0.3.0.tar.gz
- Upload date:
- Size: 17.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0a7951f6be6224d2e4007a42c852ab0511fda6995bd94815468cd7c4c09e961
|
|
| MD5 |
a405a550f8c5373a7ee5e755f3b38181
|
|
| BLAKE2b-256 |
4d302a2ccb0e812b3581492ee711e69755147f3bb626979146a7e8f5974676c6
|
Provenance
The following attestation bundles were made for mysql_shell_client-0.3.0.tar.gz:
Publisher:
release.yaml on canonical/mysql-shell-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mysql_shell_client-0.3.0.tar.gz -
Subject digest:
f0a7951f6be6224d2e4007a42c852ab0511fda6995bd94815468cd7c4c09e961 - Sigstore transparency entry: 740992314
- Sigstore integration time:
-
Permalink:
canonical/mysql-shell-client@c62af5242a6d69204746acaa430cfb1cfb306ff3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/canonical
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@c62af5242a6d69204746acaa430cfb1cfb306ff3 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file mysql_shell_client-0.3.0-py3-none-any.whl.
File metadata
- Download URL: mysql_shell_client-0.3.0-py3-none-any.whl
- Upload date:
- Size: 23.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bec27e4404a6c83eff28113f3cf6ad789873f4f5f0b93e005f0df8946b1378b
|
|
| MD5 |
dbd69834038ca6d09e4a61c9a3afdca6
|
|
| BLAKE2b-256 |
2d52f1c9d7480154bfb126d527d9650c6c6bc13b59f49494fca0e27a3f3ae296
|
Provenance
The following attestation bundles were made for mysql_shell_client-0.3.0-py3-none-any.whl:
Publisher:
release.yaml on canonical/mysql-shell-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mysql_shell_client-0.3.0-py3-none-any.whl -
Subject digest:
7bec27e4404a6c83eff28113f3cf6ad789873f4f5f0b93e005f0df8946b1378b - Sigstore transparency entry: 740992325
- Sigstore integration time:
-
Permalink:
canonical/mysql-shell-client@c62af5242a6d69204746acaa430cfb1cfb306ff3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/canonical
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@c62af5242a6d69204746acaa430cfb1cfb306ff3 -
Trigger Event:
workflow_dispatch
-
Statement type: