先贴代码:
#coding=utf-8
import csv, os, re
import MySQLdb
_PATH = 'D:/bike_sharing_data/trip_data/trip_history/'
_TABLE_NAME = 'trip_history_raw'
filelist = os.listdir(_PATH)
conn = MySQLdb.connect(
host='localhost',
port=3306,
user='root',
passwd='****',
db='bike_sharing'
)
cursor = conn.cursor()
pattern = re.compile(r'^20170[4-7]')
for filename in