-
pymysql 로 data insert카테고리 없음 2022. 11. 30. 14:38
#pandas 비사용 def csv_to_db(self, config, col_names): openpath = config.readpath if '\\' in openpath: openpath = openpath.replace('\\', '/') file = open(openpath, 'r') csvReader = csv.reader(file) cursor = self.conn.cursor() col_nms = col_names print('csvReader : ',csvReader) for row in csvReader: name = (row[0]) email = (row[1]) dept = (row[2]) salary = (row[3]) sql = """INSERT INTO employee (Name, Email, Department, Salary) VALUES (%s, %s, %s, %s)""" cursor.execute(sql, row)
반응형