Gaurav Kathale Gaurav Kathale - 11 months ago 94
MySQL Question

connection to AWS mysql instance using python

I have inserted new records into mysql. How can I insert live sensor data as new records into existing tables in my mysql AWS instance using python script?


Make sure that port (3306) is open on your AWS instance.

And that user has required access on that database.

Here values will be the one that are received from the sensors.

import MySQLdb

myDB = MySQLdb.connect(host="AWS_IP.0.0.0",port=3306,user="XXXXX",passwd="XXXXX",db="XXXXX")
cHandler = myDB.cursor()
cHandler.execute("INSERT INTO table_name ( field1, field2,...fieldN ) VALUES ( value1, value2,...valueN ); ")