From 829371ccbd2d57a8dc07059043a9c855f55bde3e Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Sat, 6 Feb 2016 08:48:10 -0800 Subject: [PATCH] add scraped tweets to the database --- src/twtxt.nim | 8 ++++++-- twtxtlist.nimble | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/twtxt.nim b/src/twtxt.nim index 5cc9663..97c696a 100644 --- a/src/twtxt.nim +++ b/src/twtxt.nim @@ -59,13 +59,17 @@ proc updateTweets*() = var users = db.getAllRows sql"select * from users" for user in users.items(): - echo user + echo "updating " & $user + let username = user[1] url = user[2] tweets = getTweetsFrom(url, username) - echo tweets + for tweet in tweets.items(): + try: + db.exec(sql"insert into tweets values(null, ?, ?, ?);", username, tweet.date.timeInfoToTime().toSeconds(), tweet.message) + except: discard sleep 300_000 # 5 minutes diff --git a/twtxtlist.nimble b/twtxtlist.nimble index 8efd8a4..75e3ffb 100644 --- a/twtxtlist.nimble +++ b/twtxtlist.nimble @@ -18,4 +18,6 @@ task db, "SQLite database prompt": task run, "Run app": exec "nimble build" + exec "./twtxt &" exec "./twtxtlist" + exec "killall twtxt"