import dbcon
import pymysql
import datetime
import UTIL_SLACK_CALL
db = dbcon.conn()
cursor = db.cursor(pymysql.cursors.DictCursor)
def selectStockList(cursor):
selectSql = "select ifnull(date_format(date_add(max(sr.date),interval +1 day),'%Y%m%d') "\
" , date_format(date_add(curdate( ),interval -850 day),'%Y%m%d'))as start_date "\
" ,date_format((SELECT MAX(DATE) FROM tb_stock_daily_info), '%Y%m%d') as end_date "\
" from tb_stock_daily_result sr "
cursor.execute(selectSql)
result = cursor.fetchall()
return result
#time.sleep(3600)
if __name__ == "__main__":
for vStockList in selectStockList(cursor):
now = datetime.datetime.now()
if vStockList['start_date'] <= vStockList['end_date']:
#입력파라미터 : 시작일자, 종료일자, 엔벨로퍼%(0.2 => 20%)
cursor.callproc("sp_stock_daily_result", (vStockList['start_date'], vStockList['end_date'], 0.2));
print(vStockList['start_date'], vStockList['end_date'])
dbcon.close(db)
UTIL_SLACK_CALL.send_slack("STEP_03 - Finish .. Stock_Daily_Result");