This code was working a couple weeks ago, then without changing anything, it started throwing an error. Here's the code:
#Query climate table sFrom = dateIncrement.strftime("%Y-%m-%d %H:%M:%S") sTimeStamp = dateIncrement.strftime("%Y%m%d_%H") dateToTemp = dateIncrement + delta sTo = dateToTemp.strftime("%Y-%m-%d %H:%M:%S") sQuery = "SELECT * FROM climate WHERE date_time >= '" + sFrom + "' AND date_time < '" + sTo + "'" cur = cnx.cursor() cur.execute(sQuery) iNumReturn = cur.rowcount arcpy.AddMessage("sQuery: " + sQuery) arcpy.AddMessage("iNumReturn: " + str(iNumReturn)) #Append query results to parameter lists for i in range(0,iNumReturn): row = cur.fetchone() lsSiteKey.append(row[0]) lsDatetime.append(row[1]) lsAirTemperature.append(row[9]) lsVaporPressure.append(row[11]) lsDewpoint.append(row[12]) lsSolarRadiation.append(row[13]) lsWindSpeed.append(row[14]) lsWindDirection.append(row[15]) cur.close()And here's the error:
Connection successfulsQuery: SELECT * FROM climate WHERE date_time >= '2008-03-01 08:00:00' AND date_time < '2008-03-01 09:00:00'iNumReturn: 21Failed script runGriddingTools...Traceback (most recent call last): File "C:\AA_Thesis_Project\ZZ_MySQL_Work\Python_Scripts\runGriddingTools.py", line 439, in row = cur.fetchone() File "C:\Python34\Lib\site-packages\mysql\connector\cursor.py", line 809, in fetchone row, self.description) File "C:\Python34\Lib\site-packages\mysql\connector\conversion.py", line 394, in row_to_python result = self._cache_field_types[field_type](row, field) File "C:\Python34\Lib\site-packages\mysql\connector\conversion.py", line 552, in _STRING_to_python return value.decode(self.charset) File "C:\Python27\ArcGIS10.3\Lib\encodings\utf_8.py", line 16, in decode return codecs.utf_8_decode(input, errors, True)AttributeError: 'NoneType' object has no attribute 'utf_8_decode'Failed to execute (runGriddingTools).Failed at Tue Jun 23 11:28:17 2015 (Elapsed Time: 7.97 seconds)When I run the same query in MySQL Workbench, it returns non-null data:
# Site_Key, date_time, wy, wd, year, month, day, hour, minute, tmp3, hum3, vap3, dpt3, sol, wnd3sa, wnd3d'012', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-1.50', '0.99', '534.0', '-1.60', '7.0', '4.90', '300.0''031', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-3.20', '0.99', '461.0', '-3.40', '8.0', '9.00', '314.0''076', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '0.80', '0.94', '605.0', '-0.10', '5.0', '3.30', '294.0''095b', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-1.50', '0.98', '530.0', '-1.70', '6.0', '6.50', '281.0''098c', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-0.40', '-999.00', '-999.0', '-999.00', '-999.0', '3.00', '-999.0''124', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-3.10', '0.99', '469.0', '-3.20', '12.0', '10.20', '220.0''124b', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-2.80', '0.99', '481.0', '-2.80', '11.0', '2.90', '304.0''125', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-0.80', '1.00', '573.0', '-0.80', '0.0', '1.80', '199.0''127', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-1.50', '1.00', '538.0', '-1.50', '9.0', '5.40', '297.0''128', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-4.60', '0.97', '402.0', '-5.00', '-999.0', '14.60', '294.0''13803', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-3.40', '1.01', '460.0', '-3.40', '8.0', '9.00', '-999.0''138j10', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-3.60', '1.00', '452.0', '-3.60', '8.0', '8.00', '-999.0''138l21', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-4.90', '1.00', '405.0', '-4.90', '47.0', '12.20', '291.0''144', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-2.10', '0.97', '499.0', '-2.40', '10.0', '8.00', '297.0''145', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-1.60', '1.00', '533.0', '-1.60', '4.0', '4.20', '10.0''163', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-5.20', '0.97', '383.0', '-5.60', '11.0', '11.40', '302.0''166b', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-4.50', '0.98', '411.0', '-4.70', '6.0', '9.70', '297.0''167', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-3.80', '1.02', '446.0', '-3.80', '4.0', '5.30', '298.0''174', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-4.20', '0.97', '418.0', '-4.50', '9.0', '3.10', '224.0''176', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-4.10', '0.97', '422.0', '-4.50', '8.0', '7.40', '287.0''rmsp3', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-4.50', '1.00', '418.0', '-4.50', '3.0', '282.00', '2.6'Can someone shed some light on this confusing situation? Thanks!
أكثر...
#Query climate table sFrom = dateIncrement.strftime("%Y-%m-%d %H:%M:%S") sTimeStamp = dateIncrement.strftime("%Y%m%d_%H") dateToTemp = dateIncrement + delta sTo = dateToTemp.strftime("%Y-%m-%d %H:%M:%S") sQuery = "SELECT * FROM climate WHERE date_time >= '" + sFrom + "' AND date_time < '" + sTo + "'" cur = cnx.cursor() cur.execute(sQuery) iNumReturn = cur.rowcount arcpy.AddMessage("sQuery: " + sQuery) arcpy.AddMessage("iNumReturn: " + str(iNumReturn)) #Append query results to parameter lists for i in range(0,iNumReturn): row = cur.fetchone() lsSiteKey.append(row[0]) lsDatetime.append(row[1]) lsAirTemperature.append(row[9]) lsVaporPressure.append(row[11]) lsDewpoint.append(row[12]) lsSolarRadiation.append(row[13]) lsWindSpeed.append(row[14]) lsWindDirection.append(row[15]) cur.close()And here's the error:
Connection successfulsQuery: SELECT * FROM climate WHERE date_time >= '2008-03-01 08:00:00' AND date_time < '2008-03-01 09:00:00'iNumReturn: 21Failed script runGriddingTools...Traceback (most recent call last): File "C:\AA_Thesis_Project\ZZ_MySQL_Work\Python_Scripts\runGriddingTools.py", line 439, in row = cur.fetchone() File "C:\Python34\Lib\site-packages\mysql\connector\cursor.py", line 809, in fetchone row, self.description) File "C:\Python34\Lib\site-packages\mysql\connector\conversion.py", line 394, in row_to_python result = self._cache_field_types[field_type](row, field) File "C:\Python34\Lib\site-packages\mysql\connector\conversion.py", line 552, in _STRING_to_python return value.decode(self.charset) File "C:\Python27\ArcGIS10.3\Lib\encodings\utf_8.py", line 16, in decode return codecs.utf_8_decode(input, errors, True)AttributeError: 'NoneType' object has no attribute 'utf_8_decode'Failed to execute (runGriddingTools).Failed at Tue Jun 23 11:28:17 2015 (Elapsed Time: 7.97 seconds)When I run the same query in MySQL Workbench, it returns non-null data:
# Site_Key, date_time, wy, wd, year, month, day, hour, minute, tmp3, hum3, vap3, dpt3, sol, wnd3sa, wnd3d'012', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-1.50', '0.99', '534.0', '-1.60', '7.0', '4.90', '300.0''031', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-3.20', '0.99', '461.0', '-3.40', '8.0', '9.00', '314.0''076', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '0.80', '0.94', '605.0', '-0.10', '5.0', '3.30', '294.0''095b', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-1.50', '0.98', '530.0', '-1.70', '6.0', '6.50', '281.0''098c', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-0.40', '-999.00', '-999.0', '-999.00', '-999.0', '3.00', '-999.0''124', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-3.10', '0.99', '469.0', '-3.20', '12.0', '10.20', '220.0''124b', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-2.80', '0.99', '481.0', '-2.80', '11.0', '2.90', '304.0''125', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-0.80', '1.00', '573.0', '-0.80', '0.0', '1.80', '199.0''127', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-1.50', '1.00', '538.0', '-1.50', '9.0', '5.40', '297.0''128', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-4.60', '0.97', '402.0', '-5.00', '-999.0', '14.60', '294.0''13803', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-3.40', '1.01', '460.0', '-3.40', '8.0', '9.00', '-999.0''138j10', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-3.60', '1.00', '452.0', '-3.60', '8.0', '8.00', '-999.0''138l21', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-4.90', '1.00', '405.0', '-4.90', '47.0', '12.20', '291.0''144', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-2.10', '0.97', '499.0', '-2.40', '10.0', '8.00', '297.0''145', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-1.60', '1.00', '533.0', '-1.60', '4.0', '4.20', '10.0''163', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-5.20', '0.97', '383.0', '-5.60', '11.0', '11.40', '302.0''166b', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-4.50', '0.98', '411.0', '-4.70', '6.0', '9.70', '297.0''167', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-3.80', '1.02', '446.0', '-3.80', '4.0', '5.30', '298.0''174', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-4.20', '0.97', '418.0', '-4.50', '9.0', '3.10', '224.0''176', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-4.10', '0.97', '422.0', '-4.50', '8.0', '7.40', '287.0''rmsp3', '2008-03-01 08:00:00', '2008', '153', '2008', '3', '1', '8', '0', '-4.50', '1.00', '418.0', '-4.50', '3.0', '282.00', '2.6'Can someone shed some light on this confusing situation? Thanks!
أكثر...