twitools/makedb.py
Klaus-Uwe Mitterer 19ae6e4a31 Move common functions to tools.py
Move gethandles and gethashtags into getmentions
Make getmentions and makedb use tools
2015-04-21 23:07:25 +02:00

24 lines
739 B
Python
Executable file

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import tools
import sys
def makeDB(path=tools.config.dbpath):
if tools.fileExists(path):
raise IOError(path + " already exists. If you want to recreate it, please delete it first, or provide a different file name.")
db = tools.dbObject(path)
db.executeQuery("CREATE TABLE tweets(`tweet_id` INTEGER NOT NULL, `in_reply_to_status_id` TEXT, `in_reply_to_user_id` TEXT, `timestamp` TEXT, `source` TEXT, `text` TEXT, `retweeted_status_id` TEXT, `retweeted_status_user_id` TEXT, `retweeted_status_timestamp` TEXT, `expanded_urls` TEXT, PRIMARY KEY(tweet_id));")
db.commit()
db.closeConnection()
if __name__ == "__main__":
try:
makeDB(sys.argv[1])
except IndexError:
makeDB()