From d7f13b3a71ec29efacb43693c0546ee3524762cd Mon Sep 17 00:00:00 2001 From: Guilhem Saurel Date: Fri, 25 Mar 2016 20:14:54 +0100 Subject: [PATCH] Twitter: Avoid duplicate primary key at database level --- twitter/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/twitter/__init__.py b/twitter/__init__.py index 05723fa..ae091f4 100644 --- a/twitter/__init__.py +++ b/twitter/__init__.py @@ -58,6 +58,6 @@ def already_said(id): self.bot.say({'text': text, 'xhtml': xhtml}) tweets.add(tweet['id']) last_tweet.last = timeline[0]['id'] - for tweet in tweets - set(t[0] for t in self.bot.session.query(LastTweets.last).all()): - self.bot.session.add(Tweets(id=tweet)) + for tweet in tweets: + self.bot.session.merge(Tweets(id=tweet)) self.bot.session.commit()