From 3adcaf2be55d6bd18cc6d7c48e7b20bae9ef018c Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Tue, 16 Dec 2025 18:15:07 +0000 Subject: [PATCH 1/4] Updated Connector/Python version to v9.6.0 Change-Id: I0948c0310b33ce3eaeb7b96865e98f310250548b --- CHANGES.txt | 5 +++++ .../cpydist/data/rpm/mysql-connector-python.spec | 13 ++++++++----- .../lib/mysql/connector/version.py | 2 +- mysql-connector-python/src/version_info.rc | 4 ++-- .../cpydist/data/rpm/mysql-connector-python.spec | 13 ++++++++----- mysqlx-connector-python/lib/mysqlx/version.py | 2 +- 6 files changed, 25 insertions(+), 14 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 8b3b3a43..364c34de 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -8,6 +8,11 @@ Copyright (c) 2009, 2025, Oracle and/or its affiliates. Full release notes: http://dev.mysql.com/doc/relnotes/connector-python/en/ +v9.6.0 +====== + +This release contains no functional changes. + v9.5.0 ====== diff --git a/mysql-connector-python/cpydist/data/rpm/mysql-connector-python.spec b/mysql-connector-python/cpydist/data/rpm/mysql-connector-python.spec index 09afcc34..280631eb 100644 --- a/mysql-connector-python/cpydist/data/rpm/mysql-connector-python.spec +++ b/mysql-connector-python/cpydist/data/rpm/mysql-connector-python.spec @@ -40,7 +40,7 @@ %{?extra_link_args: %global extra_link_args %{extra_link_args}} # set version if not defined through 'rpmbuild' -%{!?version: %global version 9.5.0} +%{!?version: %global version 9.6.0} %global with_openssl_opts "" @@ -174,14 +174,17 @@ cd mysql-connector-python %{python3_sitearch}/_mysql_connector.cpython*.so %changelog -* Mon Jul 23 2025 Souma Kanti Ghosh - 9.5.0-1 +* Tue Dec 16 2025 Filipe Silva - 9.6.0-1 +- Updated for 9.6.0 + +* Mon Jul 23 2025 Souma Kanti Ghosh - 9.5.0-2 - Updated for 9.5.0 * Wed Jul 16 2025 Oscar Pacheco - 9.5.0-1 - Removed Python 3.9 support - Added Python 3.12 support for EL 8 and 9 -* Mon Jun 9 2025 Oscar Pacheco - 9.4.0-1 +* Mon Jun 9 2025 Oscar Pacheco - 9.4.0-2 - Updated for 9.4.0 * Fri May 30 2025 Souma Kanti Ghosh - 9.4.0-1 @@ -194,7 +197,7 @@ cd mysql-connector-python * Mon Oct 28 2024 Souma Kanti Ghosh - 9.2.0-1 - Updated for 9.2.0 -* Wed Sep 11 2024 Oscar Pacheco - 9.1.0-1 +* Wed Sep 11 2024 Oscar Pacheco - 9.1.0-2 - Updated for 9.1.0 * Wed Jul 31 2024 Souma Kanti Ghosh - 9.1.0-1 @@ -208,7 +211,7 @@ cd mysql-connector-python * Wed Feb 28 2024 Oscar Pacheco - 8.4.0-1 - Updated for 8.4.0 -* Wed Dec 6 2023 Oscar Pacheco - 8.3.0-1 +* Wed Dec 6 2023 Oscar Pacheco - 8.3.0-2 - Updated Python version for openSUSE 15 from 3.9 to 3.11 * Fri Dec 1 2023 Oscar Pacheco - 8.3.0-1 diff --git a/mysql-connector-python/lib/mysql/connector/version.py b/mysql-connector-python/lib/mysql/connector/version.py index 0948bbbe..02f93f86 100644 --- a/mysql-connector-python/lib/mysql/connector/version.py +++ b/mysql-connector-python/lib/mysql/connector/version.py @@ -32,7 +32,7 @@ as mysql.connector.version. """ -VERSION = (9, 5, 0, "", 1) +VERSION = (9, 6, 0, "", 1) # pylint: disable=consider-using-f-string if VERSION[3] and VERSION[4]: diff --git a/mysql-connector-python/src/version_info.rc b/mysql-connector-python/src/version_info.rc index 08699326..ddd2bd35 100644 --- a/mysql-connector-python/src/version_info.rc +++ b/mysql-connector-python/src/version_info.rc @@ -34,8 +34,8 @@ #include #include -#define CONPY_VERSION "9.5.0" -#define CONPY_VERSION_RAW 9,5,0,0 +#define CONPY_VERSION "9.6.0" +#define CONPY_VERSION_RAW 9,6,0,0 // Set up debug information #if DBG diff --git a/mysqlx-connector-python/cpydist/data/rpm/mysql-connector-python.spec b/mysqlx-connector-python/cpydist/data/rpm/mysql-connector-python.spec index 87715df7..3e401887 100644 --- a/mysqlx-connector-python/cpydist/data/rpm/mysql-connector-python.spec +++ b/mysqlx-connector-python/cpydist/data/rpm/mysql-connector-python.spec @@ -41,7 +41,7 @@ %{?extra_link_args: %global extra_link_args %{extra_link_args}} # set version if not defined through 'rpmbuild' -%{!?version: %global version 9.5.0} +%{!?version: %global version 9.6.0} # if true set byte_code_only to --byte_code_only @@ -174,14 +174,17 @@ sed -i -e '/Requires-Dist: protobuf/d' %{buildroot}%{python3_sitearch}/mysqlx_co %{python3_sitearch}/_mysqlxpb.cpython*.so %changelog -* Mon Jul 23 2025 Souma Kanti Ghosh - 9.5.0-1 +* Tue Dec 16 2025 Filipe Silva - 9.6.0-1 +- Updated for 9.6.0 + +* Mon Jul 23 2025 Souma Kanti Ghosh - 9.5.0-2 - Updated for 9.5.0 * Wed Jul 16 2025 Oscar Pacheco - 9.5.0-1 - Removed Python 3.9 support - Added Python 3.12 support for EL 8 and 9 -* Mon Jun 9 2025 Oscar Pacheco - 9.4.0-1 +* Mon Jun 9 2025 Oscar Pacheco - 9.4.0-2 - Updated for 9.4.0 * Fri May 30 2025 Souma Kanti Ghosh - 9.4.0-1 @@ -194,7 +197,7 @@ sed -i -e '/Requires-Dist: protobuf/d' %{buildroot}%{python3_sitearch}/mysqlx_co * Mon Oct 28 2024 Souma Kanti Ghosh - 9.2.0-1 - Updated for 9.2.0 -* Wed Sep 11 2024 Oscar Pacheco - 9.1.0-1 +* Wed Sep 11 2024 Oscar Pacheco - 9.1.0-2 - Updated for 9.1.0 * Mon Aug 5 2024 Souma Kanti Ghosh - 9.1.0-1 @@ -208,7 +211,7 @@ sed -i -e '/Requires-Dist: protobuf/d' %{buildroot}%{python3_sitearch}/mysqlx_co * Wed Feb 28 2024 Oscar Pacheco - 8.4.0-1 - Updated for 8.4.0 -* Wed Dec 6 2023 Oscar Pacheco - 8.3.0-1 +* Wed Dec 6 2023 Oscar Pacheco - 8.3.0-2 - Updated Python version for openSUSE 15 from 3.9 to 3.11 * Fri Dec 1 2023 Oscar Pacheco - 8.3.0-1 diff --git a/mysqlx-connector-python/lib/mysqlx/version.py b/mysqlx-connector-python/lib/mysqlx/version.py index 3a37337c..3afa3561 100644 --- a/mysqlx-connector-python/lib/mysqlx/version.py +++ b/mysqlx-connector-python/lib/mysqlx/version.py @@ -32,7 +32,7 @@ as mysqlx.version. """ -VERSION = (9, 5, 0, "", 1) +VERSION = (9, 6, 0, "", 1) # pylint: disable=consider-using-f-string if VERSION[3] and VERSION[4]: From dff090c5d7806e9ef131db024f7cad03e4e88563 Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Tue, 16 Dec 2025 18:26:28 +0000 Subject: [PATCH 2/4] Updated GPL licence book Change-Id: I77d9a027f85060f38da367c4b98461259680a849 --- LICENSE.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index c59e8b23..b38e594b 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ Licensing Information User Manual -MySQL Connector/Python 9.5.0 Community +MySQL Connector/Python 9.6.0 Community __________________________________________________________________ Introduction @@ -8,18 +8,18 @@ Introduction This License Information User Manual contains Oracle's product license and other licensing information, including licensing information for third-party software which may be included in this distribution of - MySQL Connector/Python 9.5.0 Community. + MySQL Connector/Python 9.6.0 Community. - Last updated: September 2025 + Last updated: December 2025 Licensing Information - This release of MySQL Connector/Python 9.5.0 Community is brought to + This release of MySQL Connector/Python 9.6.0 Community is brought to you by the MySQL team at Oracle. This software is released under version 2 of the GNU General Public License (GPLv2), as set forth below, with the following additional permissions: - This distribution of MySQL Connector/Python 9.5.0 Community is designed + This distribution of MySQL Connector/Python 9.6.0 Community is designed to work with certain software (including but not limited to OpenSSL) that is licensed under separate terms, as designated in a particular file or component or in the license documentation. Without limiting From 8cb8ab5e7f76f5029d2a1ed89356dd5034f58498 Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Tue, 16 Dec 2025 19:04:53 +0000 Subject: [PATCH 3/4] Update copyright year Change-Id: Idebfe9faad6ec2c7b3aca63a6733956509c9f6d7 --- CHANGES.txt | 2 +- README.txt | 2 +- .../cpydist/data/rpm/mysql-connector-python.spec | 3 +-- .../cpydist/data/rpm/mysql-connector-python.spec | 3 +-- mysqlx-connector-python/docs/mysqlx/conf.py | 2 +- mysqlx-connector-python/docs/mysqlx/license.rst | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 364c34de..2af95802 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -3,7 +3,7 @@ MySQL Connector/Python - Release Notes & Changes ==================================================== MySQL Connector/Python -Copyright (c) 2009, 2025, Oracle and/or its affiliates. +Copyright (c) 2009, 2026, Oracle and/or its affiliates. Full release notes: http://dev.mysql.com/doc/relnotes/connector-python/en/ diff --git a/README.txt b/README.txt index 9b8eced2..ea08d398 100644 --- a/README.txt +++ b/README.txt @@ -1,4 +1,4 @@ -Copyright (c) 2009, 2025, Oracle and/or its affiliates. +Copyright (c) 2009, 2026, Oracle and/or its affiliates. This is a release of MySQL Connector/Python, Oracle's Python driver for MySQL. diff --git a/mysql-connector-python/cpydist/data/rpm/mysql-connector-python.spec b/mysql-connector-python/cpydist/data/rpm/mysql-connector-python.spec index 280631eb..cf485bd7 100644 --- a/mysql-connector-python/cpydist/data/rpm/mysql-connector-python.spec +++ b/mysql-connector-python/cpydist/data/rpm/mysql-connector-python.spec @@ -30,7 +30,6 @@ %undefine _package_note_file %define _build_id_links none -%define current_year %(date +%Y) %global __python3 /usr/bin/python3.12 %global python3_pkgversion 3.12 @@ -69,7 +68,7 @@ Summary: Standardized MySQL database driver for Python Name: mysql-connector-python%{?product_suffix} Version: %{version} Release: 1%{?version_extra:.%{version_extra}}%{?byte_code_only:.1}%{?dist} -License: Copyright (c) 2015, %{current_year}, Oracle and/or its affiliates. Under %{?lic_type} license as shown in the Description field. +License: Copyright (c) 2015, 2026, Oracle and/or its affiliates. Under %{?lic_type} license as shown in the Description field. URL: https://dev.mysql.com/downloads/connector/python/ Source0: https://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python%{?product_suffix}-%{version}-src.tar.gz diff --git a/mysqlx-connector-python/cpydist/data/rpm/mysql-connector-python.spec b/mysqlx-connector-python/cpydist/data/rpm/mysql-connector-python.spec index 3e401887..a452a209 100644 --- a/mysqlx-connector-python/cpydist/data/rpm/mysql-connector-python.spec +++ b/mysqlx-connector-python/cpydist/data/rpm/mysql-connector-python.spec @@ -29,7 +29,6 @@ %global wants_py_dnspython_version 2.6.1 %undefine _package_note_file -%define current_year %(date +%Y) %global __python3 /usr/bin/python3.12 %global python3_pkgversion 3.12 @@ -65,7 +64,7 @@ Summary: Standardized MySQL database driver for Python Name: mysqlx-connector-python%{?product_suffix} Version: %{version} Release: 1%{?version_extra:.%{version_extra}}%{?byte_code_only:.1}%{?dist} -License: Copyright (c) 2015, %{current_year}, Oracle and/or its affiliates. Under %{?lic_type} license as shown in the Description field. +License: Copyright (c) 2015, 2026, Oracle and/or its affiliates. Under %{?lic_type} license as shown in the Description field. URL: https://dev.mysql.com/downloads/connector/python/ Source0: https://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python%{?product_suffix}-%{version}-src.tar.gz diff --git a/mysqlx-connector-python/docs/mysqlx/conf.py b/mysqlx-connector-python/docs/mysqlx/conf.py index a3c1d64a..6fbb9a96 100644 --- a/mysqlx-connector-python/docs/mysqlx/conf.py +++ b/mysqlx-connector-python/docs/mysqlx/conf.py @@ -66,7 +66,7 @@ # General information about the project. project = "MySQL Connector/Python X DevAPI Reference" -copyright = "2016, 2024, Oracle and/or its affiliates. All rights reserved" +copyright = "2016, 2026, Oracle and/or its affiliates. All rights reserved" author = "Nuno Mariz" # The version info for the project you're documenting, acts as replacement for diff --git a/mysqlx-connector-python/docs/mysqlx/license.rst b/mysqlx-connector-python/docs/mysqlx/license.rst index 7d3ce1f6..558569d2 100644 --- a/mysqlx-connector-python/docs/mysqlx/license.rst +++ b/mysqlx-connector-python/docs/mysqlx/license.rst @@ -1,7 +1,7 @@ License ======= - Copyright (c) 2016, 2024, Oracle and/or its affiliates. + Copyright (c) 2016, 2026, Oracle and/or its affiliates. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2.0, as From aec29d91abc43057acaf70615877e7f032a90ab4 Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Fri, 19 Dec 2025 15:52:57 +0000 Subject: [PATCH 4/4] Updated README.rst with HeatWave GenAI and ML Support & fixed some references to the X DevAPI Change-Id: I83ea14b3141eb37ecc25ea022255df8f36430dee --- .gitignore | 2 +- CONTRIBUTING.md | 4 +- README.rst | 222 +++++++++++++++++++++++++++++++++++------------- README.txt | 4 +- 4 files changed, 170 insertions(+), 62 deletions(-) diff --git a/.gitignore b/.gitignore index bb7d25f2..0fbace6c 100644 --- a/.gitignore +++ b/.gitignore @@ -24,7 +24,7 @@ docs dist build -# Classic/XDevAPI protocol connector (aka mysql) +# Classic/X DevAPI protocol connector (aka mysql) mysql*-connector-python/build/ mysql*-connector-python/dist/ mysql*-connector-python/docs/INFO_BIN diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index eccacbb4..c85ae96d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -304,13 +304,13 @@ Due to some `know limitations `_ o That being said, the following there are some examples of possible use cases: -* Running the test modules whose name follows the pattern `c.*` from a mac whose IP is `232.188.98.520`, and the password for `root` is `s3cr3t`. XDevAPI protocol listening on port `33060`: +* Running the test modules whose name follows the pattern `c.*` from a mac whose IP is `232.188.98.520`, and the password for `root` is `s3cr3t`. X DevAPI protocol listening on port `33060`: ```bash $ TEST_PATTERN='c.*' MYSQL_HOST='192.168.68.111' MYSQL_PASSWORD='s3cr3t' ./tests/docker/runner.sh ``` -* Running the *mysqlx_crud* test module from Linux with MySQL user account `root`, and password `empty_string`. XDevAPI protocol listening on port `33070`: +* Running the *mysqlx_crud* test module from Linux with MySQL user account `root`, and password `empty_string`. X DevAPI protocol listening on port `33070`: ```bash $ MYSQLX_PORT='33070' TEST_PATTERN='mysqlx_crud' ./tests/docker/runner.sh diff --git a/README.rst b/README.rst index 10178597..b408b2c0 100644 --- a/README.rst +++ b/README.rst @@ -1,71 +1,83 @@ MySQL Connector/Python ====================== -.. image:: https://img.shields.io/pypi/v/mysql-connector-python.svg - :target: https://pypi.org/project/mysql-connector-python/ -.. image:: https://img.shields.io/pypi/pyversions/mysql-connector-python.svg - :target: https://pypi.org/project/mysql-connector-python/ -.. image:: https://img.shields.io/pypi/l/mysql-connector-python.svg - :target: https://pypi.org/project/mysql-connector-python/ - -.. === ==== +.. === [repl-mysqlx("mysql-connector-python", "mysqlx-connector-python")] === + +.. image:: + https://img.shields.io/pypi/v/mysql-connector-python.svg + :target: https://pypi.org/project/mysql-connector-python/ + +.. image:: + https://img.shields.io/pypi/pyversions/mysql-connector-python.svg + :target: https://pypi.org/project/mysql-connector-python/ + +.. image:: + https://img.shields.io/pypi/l/mysql-connector-python.svg + :target: https://pypi.org/project/mysql-connector-python/ + +.. === === + +.. === [repl(" - We refer to it as the", "."), repl("`Classic API `__.", "")] ==== + MySQL Connector/Python enables Python programs to access MySQL databases, using an API that is compliant with the `Python Database API Specification v2.0 -(PEP 249) `_ - We refer to it as the -`Classic API `_. +(PEP 249) `__ - We refer to it as the +`Classic API `__. .. === ==== .. === [repl("It also", "MySQL Connector/Python")] === -It also contains an implementation of the `XDevAPI `_ + +It also contains an implementation of the `X DevAPI `__ - An Application Programming Interface for working with the `MySQL Document Store -`_. +`__. .. === === -.. === [repl("* `XDevAPI `_", "")] ==== +.. === [repl("* `X DevAPI `__", "")] ==== + Features -------- -* `Asynchronous Connectivity `_ -* `C-extension `_ -* `Telemetry `_ -* `XDevAPI `_ +* `Asynchronous Connectivity `__ +* `C-extension `__ +* `Telemetry `__ +* `X DevAPI `__ .. === ==== - Installation ------------ -Connector/Python contains the classic and XDevAPI connector APIs, which are +Connector/Python contains the Classic and X DevAPI connector APIs, which are installed separately. Any of these can be installed from a binary or source distribution. Binaries are distributed in the following package formats: -* `RPM `_ -* `WHEEL `_ +* `RPM `__ +* `WHEEL `__ On the other hand, the source code is distributed as a compressed file from which a wheel package can be built. -The recommended way to install Connector/Python is via `pip `_, +The recommended way to install Connector/Python is via `pip `__, which relies on WHEEL packages. For such a reason, it is the installation procedure that is going to be described moving forward. Please, refer to the official MySQL documentation `Connector/Python Installation -`_ to +`__ to know more about installing from an RPM, or building and installing a WHEEL package from a source distribution. -Before installing a package with `pip `_, it is strongly suggested +Before installing a package with `pip `__, it is strongly suggested to have the most recent ``pip`` version installed on your system. If your system already has ``pip`` installed, you might need to update it. Or you can use -the `standalone pip installer `_. +the `standalone pip installer `__. -.. === [repl("The *classic API* can be installed via pip as follows:", "")] === -The *classic API* can be installed via pip as follows: +.. === [repl("The *Classic API* can be installed via pip as follows:", "")] === + +The *Classic API* can be installed via pip as follows: .. code-block:: bash @@ -73,20 +85,19 @@ The *classic API* can be installed via pip as follows: .. === ==== -.. === [repl("similarly, the *XDevAPI* can be installed with:", "")] === -similarly, the *XDevAPI* can be installed with: +.. === [repl("similarly, the *X DevAPI* can be installed with:", "")] === + +similarly, the *X DevAPI* can be installed with: .. code-block:: bash $ pip install mysqlx-connector-python -Please refer to the `installation tutorial `_ -for installation alternatives of the XDevAPI. +Please refer to the `installation tutorial `__ +for installation alternatives of the X DevAPI. .. === === - -++++++++++++++++++++ Installation Options ++++++++++++++++++++ @@ -101,8 +112,9 @@ optional dependencies to unleash certain functionalities. .. === === -.. === [repl("similarly, for the XDevAPI:", "")] === -similarly, for the XDevAPI: +.. === [repl("similarly, for the X DevAPI:", "")] === + +similarly, for the X DevAPI: .. code-block:: bash @@ -115,8 +127,9 @@ This installation option can be seen as a shortcut to install all the dependencies needed by a particular feature. Mind that this is optional and you are free to install the required dependencies by yourself. -.. === [repl("Options for the Classic connector:", "Available options:")] === -Options for the Classic connector: +.. === [repl("Options for the Classic API connector:", "Available options:")] === + +Options for the Classic API connector: * dns-srv * gssapi @@ -125,17 +138,19 @@ Options for the Classic connector: .. === === -.. === [repl("Options for the XDevAPI connector:", "Available options:")] === -Options for the XDevAPI connector: +.. === [repl("Options for the X DevAPI connector:", "Available options:")] === + +Options for the X DevAPI connector: * dns-srv * compression .. === === -.. === [repl("Classic", "Sample Code"), repl("-------", "-----------")] === -Classic -------- +.. === [repl("Classic API ", ""), repl("-------", "-----------")] === + +Classic API Sample Code +----------------------- .. code:: python @@ -163,9 +178,10 @@ Classic .. === === -.. === [repl("XDevAPI", "Sample Code"), repl("-------", "-----------")] === -XDevAPI -------- +.. === [repl("X DevAPI ", ""), repl("-------", "-----------")] === + +X DevAPI Sample Code +-------------------- .. code:: python @@ -197,30 +213,122 @@ XDevAPI .. === === -.. === [repl-mysql("- `MySQL Connector/Python X DevAPI Reference `_", ""), repl-mysqlx("- `MySQL Connector/Python Developer Guide `_", "")] === +.. === === + +HeatWave GenAI and Machine Learning Support +------------------------------------------- + +MySQL Connector/Python now includes an optional API for integrating directly with MySQL HeatWave's AI and Machine Learning capabilities. This new SDK is designed to reduce the time required to generate proofs-of-concept (POCs) by providing an intuitive Pythonic interface that automates the management of SQL tables and procedures. + +The new ``mysql.ai`` module offers two primary components: + +* **GenAI:** Provides implementations of LangChain's abstract ``LLM``, ``VectorStore``, and ``Embeddings`` classes (``MyLLM``, ``MyVectorStore``, ``MyEmbeddings``). This ensures full interoperability with existing LangChain pipelines, allowing developers to easily substitute existing components with HeatWave-backed versions. +* **AutoML:** Provides Scikit-Learn compatible estimators (``MyClassifier``, ``MyRegressor``, ``MyAnomalyDetector``, ``MyGenericTransformer``) that inherit from standard Scikit-Learn mixins. These components accept Pandas DataFrames and can be dropped directly into existing Scikit-Learn pipelines and grid searches. + +**Note on Dependencies:** These features introduce dependencies on ``langchain``, ``pandas``, and ``scikit-learn``. To keep existing installations unchanged and the base connector lightweight, these dependencies are **not installed by default**. You must install them separately to use the ``mysql.ai`` features. + +**Example: GenAI Chatbot with Memory** + +This example demonstrates how to use ``MyLLM`` within a loop to create a simple chatbot that maintains conversation history. + +.. code:: python + + from collections import deque + from mysql import connector + from mysql.ai.genai import MyLLM + + def run_chatbot(db_connection, chat_history_size=5): + # Initialize MyLLM with the database connection + my_llm = MyLLM(db_connection) + + # Maintain a limited history for context + chat_history = deque(maxlen=chat_history_size) + system_msg = "System: You are a helpful AI assistant." + + while True: + user_input = input("\nUser: ") + if user_input.lower() in ["exit", "quit"]: + break + + # Format history and invoke the LLM + history = [system_msg] + list(chat_history) + [f"User: {user_input}"] + prompt = "\n".join(history) + + # Invoke HeatWave GenAI + response = my_llm.invoke(prompt) + print(f"Bot: {response}") + + # Update history + chat_history.append(f"User: {user_input}") + chat_history.append(f"Bot: {response}") + + # Usage + with connector.connect(user='root', database='mlcorpus') as db_connection: + run_chatbot(db_connection) + +**Example: HeatWave AutoML in a Scikit-Learn Pipeline** + +This example shows how to use ``MyClassifier`` as a drop-in replacement within a standard Scikit-Learn pipeline. + +.. code:: python + + import pandas as pd + from mysql import connector + from sklearn.pipeline import Pipeline + from sklearn.preprocessing import StandardScaler + from mysql.ai.ml import MyClassifier + + # 1. Setup Data (Pandas DataFrame) + X = pd.DataFrame([[0.5, 0.1], [1.0, 0.8], [0.1, 0.2]], columns=["feat1", "feat2"]) + y = pd.Series([0, 1, 0], name="target") + + # 2. Connect and Train + with connector.connect(user='root', database='mlcorpus') as db_connection: + # Initialize the HeatWave classifier + clf = MyClassifier(db_connection) + + # Create a standard Scikit-Learn pipeline + pipe = Pipeline([ + ("scaler", StandardScaler()), + ("mysql_clf", clf) + ]) + + # Fit the model (automates upload and training on HeatWave) + pipe.fit(X, y) + + # Predict + preds = pipe.predict(X) + print(f"Predictions: {preds}") + + # Score + score = pipe.score(X, y) + print(f"Accuracy: {score}") + +.. === === + +.. === [repl-mysql("- `MySQL Connector/Python X DevAPI Reference `__", ""), repl-mysqlx("- `MySQL Connector/Python Developer Guide `__", "")] === + Additional Resources -------------------- -- `MySQL Connector/Python Developer Guide `_ -- `MySQL Connector/Python X DevAPI Reference `_ -- `MySQL Connector/Python Forum `_ -- `MySQL Public Bug Tracker `_ -- `Slack `_ (`Sign-up `_ required if you do not have an Oracle account) -- `Stack Overflow `_ -- `Oracle Blogs `_ +- `MySQL Connector/Python Developer Guide `__ +- `MySQL Connector/Python X DevAPI Reference `__ +- `MySQL Connector/Python Forum `__ +- `MySQL Public Bug Tracker `__ +- `Slack `__ (`Sign-up `__ required if you do not have an Oracle account) +- `Stack Overflow `__ +- `Oracle Blogs `__ .. === === - Contributing ------------ There are a few ways to contribute to the Connector/Python code. Please refer -to the `contributing guidelines `_ for additional information. - +to the `contributing guidelines `__ for additional information. License ------- -Please refer to the `README.txt `_ and `LICENSE.txt `_ +Please refer to the `README.txt `__ and `LICENSE.txt `__ files, available in this repository, for further details. diff --git a/README.txt b/README.txt index ea08d398..0409b348 100644 --- a/README.txt +++ b/README.txt @@ -4,14 +4,14 @@ This is a release of MySQL Connector/Python, Oracle's Python driver for MySQL. MySQL Connector/Python enables Python programs to access MySQL databases, using an API that is compliant with the Python Database API Specification -v2.0 (PEP 249). It also contains an implementation of the XDevAPI. +v2.0 (PEP 249). It also contains an implementation of the X DevAPI. License information can be found in the LICENSE.txt file. This distribution may include materials developed by third parties. For license and attribution notices for these materials, please refer to the LICENSE.txt file. -For more information on MySQL Connector/Python XDevAPI, visit +For more information on MySQL Connector/Python X DevAPI, visit https://dev.mysql.com/doc/dev/connector-python/ For additional downloads and the source of MySQL Connector/Python, visit