petykowski / room-219

A small Python application that measures the room temperature and stores it to a MySQL Database.
server.myprevio.us
0 stars 0 forks source link

Ability to Handle Inability to Connect to MySQL Database #1

Open petykowski opened 8 years ago

petykowski commented 8 years ago

Description of Problem

MySQL server is susceptible to connection errors. Most recently a power outage caused the MySQL database to become unavailable, as a result the process quit and had to be manually restarted. There should be support to handle a dropped/lost connection to the MySQL server. A traceback from the most recent failure provided below.

Traceback

Traceback (most recent call last):
  File "Room219.py", line 41, in <module>
    cursor.execute(currentID)
  File "/usr/local/lib/python2.7/dist-packages/pymysql$
    result = self._query(query)
  File "/usr/local/lib/python2.7/dist-packages/pymysql$
    conn.query(q)
  File "/usr/local/lib/python2.7/dist-packages/pymysql$
    self._affected_rows = self._read_query_result(unbu$
  File "/usr/local/lib/python2.7/dist-packages/pymysql$
    result.read()
  File "/usr/local/lib/python2.7/dist-packages/pymysql$
    first_packet = self.connection._read_packet()
  File "/usr/local/lib/python2.7/dist-packages/pymysql$
    packet_header = self._read_bytes(4)
  File "/usr/local/lib/python2.7/dist-packages/pymysql$
    "Lost connection to MySQL server during query (%s)$
pymysql.err.OperationalError: (2013, 'Lost connection $
petykowski commented 8 years ago

Researching Error Handling and Exceptions

Resourses

http://dev.mysql.com/doc/connector-python/en/connector-python-api-errors.html