Is it possible to connect my python code to mysql service instance in PCF? if yes, how to populate connection details in the code below? any suggestions. I want to run the python code in my local machine.
Code:
import mysql.connector
from mysql.connector import Error
try:
connection = mysql.connector.connect(host='XXXXXXX',
database='XXXXXXXXX',
user='XXXXX',
password='XXXXXXXXX')
mySql_Create_Table_Query = """CREATE TABLE example(
Id int(11) NOT NULL,
Name varchar(250) NOT NULL) """
cursor = connection.cursor()
result = cursor.execute(mySql_Create_Table_Query)
print("btp Table created successfully ")
except mysql.connector.Error as error:
print("Failed to create table in MySQL: {}".format(error))
finally:
if (connection.is_connected()):
cursor.close()
connection.close()
print("MySQL connection is closed")