
import csv
import dataset
# 開啟 CSV 檔案
db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/microfilm?charset=utf8mb4')
with open('youtubeReport.csv', newline='',encoding='UTF-8') as csvfile:

  # 讀取 CSV 檔案內容
    rows = csv.reader(csvfile)

  # 以迴圈輸出每一列
    for row in rows:
        print(row[5])
        db['ytVideos'].insert({'channelTitle':row[0],'subscribes':row[1],'description':row[2]
        ,'videoTitle':row[3],'publishedAt':row[4],'viewCount':row[5],'likeCount':row[6],'favoriteCount':row[7]})
db.close()