I'm new to python. Previously I used PHP with MySQL; now learning python. At this point, I'm learning to work with MySQL.
I have connected to the database using the code bellow:
import mysql.connector
cnx = mysql.connector.connect(user="myUser", password="myPass", host="localhost", database="myDb")
The connection seems to work properly and I can query items from the database using the "cursor":
sql = "SELECT * FROM..."
cnx.cursor.execute(sql)
The problem is, when I use the "escape_string" method of the connection like bellow:
escaped_string = cnx.escape_string("some SQL invalid 'terms'")
I get :
AttributeError: 'MySQLConnection' object has no attribute 'escape_string'.
I thought it's a bug related to the mysql_connector, so I thought updating may help.
pip install --upgrade mysql_connector
This updated mysql_connector but didn't solve the problem.
I'm using python 3.7.1 and mysql_connector 2.1.6