【发布时间】:2016-05-23 19:03:43
【问题描述】:
我有这段代码可以将数据保存在 cvs 文件中,现在我想将该数据保存到 sqlite 或 mysql,但它应该像保存在 cvs 中的数据库中的记录一样保存 还有一个问题 这个数据大小将是每天 30-40MB 我应该使用哪个数据库 mysql 或 PostgresSql 因为我每个月都有 1GB+ 数据库 我的想法是制作一个包含所有趋势统计数据的网站,我想将它与 django 一起使用
import tweepy
import csv #Import csv
auth = tweepy.auth.OAuthHandler('XXXXXX', 'XXXXXXX')
auth.set_access_token('XXX-XXX', 'XXX')
api = tweepy.API(auth)
# Open/Create a file to append data
csvFile = open('result.csv', 'a')
#Use csv Writer
csvWriter = csv.writer(csvFile)
for tweet in tweepy.Cursor(api.search,
q="google",
since="2016-05-22",
until="2016-05-23",
lang="en").items():
#Write a row to the csv file/ I use encode utf-8
csvWriter.writerow([tweet.created_at, tweet.text.encode('utf-8')])
print tweet.created_at, tweet.text
csvFile.close()
【问题讨论】:
标签: python mysql sqlite tweepy