Hi, I am new to python anywhere. I created my first app with flask and it is working cool.
I am trying to connect SQL database with in my app and externally from local server.
in python anywhere server it is working fine, if I try the same from my local machine. it is not working. can you guide me, how to achieve this.
I used following code:
import MySQLdb
username = 'xxxx'
password = 'yyyy'
hostname = 'xxxx.mysql.pythonanywhere-services.com'
db = 'xxxx$default'
conn = MySQLdb.connect(host=hostname, user=username, passwd=password, db=db)
cursor = conn.cursor()
cursor.execute('SELECT * from table1')
row = cursor.fetchone()
print(row)
conn.close()