import pandas as pd
import pymysql
df = pd.read_csv('C:/devtools/python_work/find_safe_city/부산_보행노인_사고다발정보_좌표_2018_2020.csv',engine='python')
df.head()
디비에 넣을 거니깐 타입을 중요하게 봐야한다
df.info()
conn = pymysql.connect( #pymysql 라이브러리 사용 DB연결
host='localhost',
user='root',
password='root',
db='final',
charset='utf8')
cursor=conn.cursor()
print('start to insert')
for index, row in df.iterrows():
cursor.execute('INSERT INTO final.sago_dabal(year, address, gugun, sago_cnt, vic_cnt, dead_cnt, heavy_cnt, light_cnt, call_cnt, lat, lng, dong, detail_addr) VALUES(%d,%s,%s,%d,%d,%d,%d,%d,%d,%f,%f,%s,%s)', data)
conn.commit()
conn.close()
print('ok')
VALUES(%d,%s,%s,%d,%d,%d,%d,%d,%d,%f,%f,%s,%s
not like that
only %s