twitools/makedb.py

24 lines
739 B
Python
Raw Normal View History

2015-04-13 20:58:32 +00:00
#!/usr/bin/env python3
2015-03-09 17:32:24 +00:00
# -*- coding: utf-8 -*-
import tools
2015-03-09 17:32:24 +00:00
import sys
def makeDB(path=tools.config.dbpath):
if tools.fileExists(path):
2015-04-14 14:27:08 +00:00
raise IOError(path + " already exists. If you want to recreate it, please delete it first, or provide a different file name.")
2015-03-09 17:32:24 +00:00
db = tools.dbObject(path)
2015-04-14 14:27:08 +00:00
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));")
2015-04-14 14:27:08 +00:00
db.commit()
db.closeConnection()
2015-04-14 14:27:08 +00:00
if __name__ == "__main__":
try:
makeDB(sys.argv[1])
except IndexError:
makeDB()