This commit is contained in:
kpt
2024-07-03 19:59:09 +08:00
2 changed files with 4 additions and 5 deletions
-1
View File
@@ -1 +0,0 @@
id,likeNum,commentsLen,reposts_count,region,content,contentLen,created_at,type,detailUrl,authorAvatar,authorName,authorDetail,isVip
1 id likeNum commentsLen reposts_count region content contentLen created_at type detailUrl authorAvatar authorName authorDetail isVip
+4 -4
View File
@@ -20,13 +20,13 @@ def save_to_sql():
concatArticlePd.to_sql('article', con=engine, if_exists='replace', index=False)
concatCommentsPd.to_sql('comments', con=engine, if_exists='replace', index=False)
except:
articleNewPd = pd.read_csv('articleData.csv')
commentNewPd = pd.read_csv('articleComments.csv')
articleNewPd = pd.read_csv('article.csv')
commentNewPd = pd.read_csv('comments.csv')
articleNewPd.to_sql('article',con=engine,if_exists='replace',index=False)
commentNewPd.to_sql('comments',con=engine,if_exists='replace',index=False)
os.remove('./articleData.csv')
os.remove('./articleComments.csv')
os.remove('./article.csv')
os.remove('./comments.csv')
if __name__ == '__main__':
save_to_sql()