I am connecting a Python program in Visual Studio Code to a SQL databse stored in MySQL Workbench 8.0. I am using the PyMySQL connector to do this. However, I am running into an error with code that I have used from another question that I have posted. Here is the link and the code:
How do I connect a Python program in Visual Studio Code to MySQL Workbench 8.0?
pip install PyMySQL
import pymysql
con = pymysql.Connect(
host='localhost',
port=3306,
user='root',
password='123456',
db='test',
charset='utf8'
)
cur = con.cursor()
sql1 = 'select * from student'
cur.execute(sql1)
data = cur.fetchall()
cur.close()
con.close()
for i in data:
print(str(i))
Here is a screenshot with my code and the error that I received.
I tried the code that I recieved from my previous question, but it resulted in an another error. I am pretty sure I have copied the code correctly and the database details. I have researched the error but have been unable to find its relevance to connecting Python programs to MYSQL Workbench 8.0 with PyMySQL.

pip install pymysqlis a command, it's not a code.fetchallmethod? Is this what you mean by copying the code correctly?33060in the code in the picture?