twitools/makedb.py

22 lines
686 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
import tools
2015-03-09 17:32:24 +00:00
import sys
2015-10-10 22:10:57 +00:00
def makeDB(path=tools.dbpath()):
2015-04-21 22:42:20 +00:00
db = tools.dbHelper(path, create = True)
2015-03-09 17:32:24 +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__":
2015-04-21 22:42:20 +00:00
if len(sys.argv) > 2:
raise ValueError(sys.argv[0] + " only takes one argument, the path of the new database file.")
2015-04-14 14:27:08 +00:00
try:
makeDB(sys.argv[1])
except IndexError:
makeDB()