Skip to content

7. Use HeatWave GenAI

Frédéric Descamps edited this page Sep 25, 2025 · 4 revisions

It's also possible to directly use GenAI capabilities from the MySQL HeatWave database.

When you are connected to the MySQL HeatWave instance you have deployed, you can call some HeatWave AI procedures from your program.

Connecting in Python to your DB System

To use MySQL in our Python application, we need to install the python-mysql-connector:

[opc@webserver ~]$ sudo dnf install -y pip
[opc@webserver ~]$ pip install mysql-connector-python

We already saw how we can connect, now let's connect from an application (a minimal Python script running on our compute instance):

import mysql.connector

conn = mysql.connector.connect(
        host = "10.0.1.57",
        user = "admin",
        password = "xxxxxxx"
        )

cursor = conn.cursor()

cursor.execute("select @@vewrsion")
rows = cursor.fetchall()

for row in rows:
    print(row)

And when we run it, we can see:

[opc@webserver ~]$ python test_hw.py 
('9.4.1-cloud',)

Using HeatWave GenAI

We can do the same using a GenAI function provided by MySQL HeatWave:

import mysql.connector

conn = mysql.connector.connect(
        host = "10.0.1.57",
        user = "admin",
        password = "xxxxxxxx"
        )

cursor = conn.cursor()

cursor.execute("call sys.HEATWAVE_CHAT(\"What is MySQL HeatWave?\")")
rows = cursor.fetchall()

for row in rows:
    print(row)

And this is the output:

Screenshot From 2025-09-24 16-54-49

More Info

Let's recap in video:

07_HeatWave_GenAI_V1.mp4

Clone this wiki locally