Ver código fonte

Modified an error

Kanggu Park 4 anos atrás
pai
commit
6ab1b958c4
1 arquivos alterados com 5 adições e 9 exclusões
  1. 5 9
      RealTimeDataAccumulator.py

+ 5 - 9
RealTimeDataAccumulator.py

@@ -403,15 +403,6 @@ if __name__ == "__main__" :
 	while True:		
 		now = datetime.now()
 		if now.hour == 1 and now.minute <= 15:				## 하루에 한번 오전 1시 이후에 과거 데이터 체크 (오전 1시는 임의로 정한 시각)
-			##########################################################
-			## 예보데이터 확인 후 임시데이터라면 데이터 삭제 후 삽입
-			# MSSQL Access
-			conn = pymssql.connect(host = targetDBIP, user = targetDBUserID, password = targetDBUserPW, database = targetDBName, autocommit=True)
-			# Create Cursor from Connection
-			cursor = conn.cursor()	
-			cursor.execute("DELETE " + targetDBName + ".dbo.BemsMonitoringPointWeatherForecasted where SiteId = 1 and BaseDateTime ='" +(now - timedelta(days=2)).strftime('%Y-%m-%d 01:00:00') + "' and ForecastedDateTime >= '" + (now - timedelta(days=1)).strftime('%Y-%m-%d 00:00:00') + "' order by CreatedDateTime desc")		
-			conn.close()
-			##########################################################
 			Check_Restoring_Unknown_past_data(targetDBIP, targetDBUserID, targetDBUserPW, targetDBName, nx, ny)		## 과거 실 데이터가 어제까지만 제공되기 때문에 매일 어제 데이터가 있는지 체크
 		if now.hour == 20 and now.minute >= 45 and now.minute <= 59:
 			AccumulationActive = True
@@ -433,6 +424,11 @@ if __name__ == "__main__" :
 			# Create Cursor from Connection
 			cursor = conn.cursor()		
 			
+			##########################################################
+			## 기존 예보데이터가 임시데이터라면 데이터 삭제 후 삽입
+			cursor.execute("DELETE " + targetDBName + ".dbo.BemsMonitoringPointWeatherForecasted where SiteId = 1 and BaseDateTime ='" +(now - timedelta(days=2)).strftime('%Y-%m-%d 01:00:00') + "' and ForecastedDateTime >= '" + (now - timedelta(days=1)).strftime('%Y-%m-%d 00:00:00') + "' ")					
+			##########################################################
+			
 			for i in range(1, len(TempWF)):
 				baseDate = TempWF[i][0]
 				baseTime = TempWF[i][1]