def METHOD_NAME(self,e):
    if not self.persist:
        return
    try:
        conn = pyodbc.connect(self.connectstring)
        conn.autocommit = True
        cursor = conn.cursor()
        if not cursor.tables(table='state').fetchone():
            print("trying to restore, but no 'state' table found")
            return
        row = cursor.execute("select tool_in_spindle,pocket_prepped from state;").fetchone()
        if row:
            e.io.tool.pocketPrepped = row.pocket_prepped
            e.io.tool.toolInSpindle = row.tool_in_spindle
            print("restored tool=%d pocketPrepped=%d" % (row.tool_in_spindle,row.pocket_prepped))
        else:
            print("no saved state record found")
    except pyodbc.Error as msg:
        print("restore_state() failed:")
        traceback.print_exc(file=sys.stdout)
    finally:
        cursor.close()
        conn.close()