-
Notifications
You must be signed in to change notification settings - Fork 3
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.
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',)
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:
Let's recap in video: