File name
Commit message
Commit date
File name
Commit message
Commit date
import psycopg2
import csv
import pandas as pd
# Step 1: Parse the CSV data
df = pd.read_csv("/home/juni/문서/대옹_모니터링/%EB%8C%80%EC%9B%85%ED%95%98%EC%9D%B4%ED%85%8D-%EB%AA%A8%EB%8B%88%ED%84%B0%EB%A7%81-%EC%86%8C%ED%94%84%ED%8A%B8%EC%9B%A8%EC%96%B4/file/workHistory.csv") # Truncated for brevity, paste the entire CSV data here.
df = df.iloc[:,1:]
db_config = {
'dbname': 'welding',
'user': 'postgres',
'password': 'ts4430!@',
'host': 'localhost', # e.g., 'localhost'
'port': '5432', # e.g., '5432'
}
conn = psycopg2.connect(**db_config)
cursor = conn.cursor()
insert_sql = """
INSERT INTO Welding_Jobs (Welding_Job_Number, Mold_Name, Work_Start_Time, Defect_Status, Temperature, Relative_Humidity, Absolute_Humidity)
VALUES (%s, %s, %s, %s, %s, %s, %s)
"""
for index, row in df.iterrows():
cursor.execute(insert_sql, (
row['용접 작업번호'],
row['금형 이름'],
row['작업 시작 시간'],
row['불량 여부'],
row['기온'],
row['상대습도'],
row['절대습도']
))
conn.commit()
cursor.close()
conn.close()