DB 배치파일 질문 하나만 하겠습니다.ㅠㅠ 0 0 303

by 마음으로코딩 [DB 기타] 배치파일 Postgresql Python [2020.07.29 11:58:38]


cur = conn.cursor() 
l = len(anomalies)

for i in range(l):
    row = anomalies.iloc[i]
    qry = f"""
       INSERT INTO tbl_anomaly_result (mdate, udate, home_code, gas, elec, water ) 
       VALUES 
       ( NOW(), NOW(), 'G0205020605', {row['water_use_value']}, {row['gas_use_value']}, {row['elec_use_value']} ) 
       ON CONFLICT ( home_code, mdate )
       DO update set gas = excluded.gas, elec = excluded.elec, water = excluded.water;
       """
    row = cur.fetchone()
cur.execute(qry)
conn.commit()

 

파이썬으로 구현된 SQL 코드 인데용.. 이걸 배치파일로돌리면 맨위의 데이터만 읽고 저장 하더라구요.. 다음행의 데이터를 읽고 분석결과를 저장해야하는데

어떻게 해야할지 모르겠네요.

댓글등록
SQL문을 포맷에 맞게(깔끔하게) 등록하려면 code() 버튼을 클릭하여 작성 하시면 됩니다.
로그인 사용자만 댓글을 작성 할 수 있습니다. 로그인, 회원가입