Created
August 11, 2018 07:14
-
-
Save kurt-liao/601c43394b1447adac548d97f537b8a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#轉成list | |
listdata = df.values.tolist() | |
#連結資料庫 | |
conn = lite.connect("weatherapi.sqlite") | |
cur = conn.cursor() | |
cur.execute('create table if not exists weather(CITY text,DISTRICT text,GEOCODE integer,DAY timestamp,TIME timestamp,TEMP integer,TD integer,RH integer,WIND text,WS integer,BF text,AT integer,Wx text,Wx_n integer,PoP6h integer,PoP12h integer,get_day timestamp);') | |
sql = "insert into weather(CITY ,DISTRICT ,GEOCODE ,DAY ,TIME ,TEMP ,TD ,RH,WIND ,WS ,BF ,AT ,Wx ,Wx_n ,PoP6h ,PoP12h ,get_day) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)" | |
for data in listdata: | |
cur.execute(sql,(data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7],data[8],data[9],data[10],data[11],data[12],data[13],data[14],data[15],data[16])) | |
conn.commit() | |
conn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment