title: Data not getting stored in mysql using python mysql.connector
body: <p>I am connecting to MySQL from my python script, subscribing to a topic from mqtt broker and whenever I receive the data I store the data.</p>
  
  <p>code</p>
  
  <pre><code>import mysql.connector
  connection = mysql.connector.connect(host='localhost',database='db',user='',
                                     password='',auth_plugin='mysql_native_password')
  
  sql_insert_query = """      #INSERT query
  cursor = connection.cursor()
  
  def on_message(client, userdata, message):
      print("message received ")
      msg = json.loads(message.payload.decode("utf-8"))
      #processing of message
  
      cursor.execute(sql_insert_query,processed_msg)
      connection.commit()
      print('inserted in db')
  
  def on_connect(client, userdata, flags, rc): 
      print("Subscribing to topic","topic")
      client.subscribe("topic")
  
  broker_address=""
  port = 8888
  
  client = mqtt.Client(clean_session=True) #create new instance
  client.on_connect = on_connect
  client.on_message = on_message #attach function to callback
  
  print("connecting to broker")
  client.connect(broker_address, port=port) #connect to broker
  client.loop_forever() #stop the loop
  
  </code></pre>
  
  <p>So with this code saves the data when mqtt receives any message. But the there are times when mqtt doesn't receive data for more than 8 hours and then starts receiving data again.In such cases script is not storing the data which comes after 8 hours or so. I believe some kind of timeout is happening. Because when I re run the script again, data is stored in mysql db. Can someone help me understand what kind of timeout is this or how to solve this problem?</p>
  
  <p>Thanks</p>