twitterresearch
twitterresearch copied to clipboard
examples.export_retweet_text() is throwing a peewee error. Unsure how to debug.
I'm going through the tutorial but the export_retweet_text function is throwing an error in peewee. As I'm not familiar with SQL syntax or the peewee library I wondered if someone could give me a hint on debugging or resolving this issue?
here's my input. All the other functions so far have worked fine.
examples.export_retweet_text()
and here's the error message I get:
---------------------------------------------------------------------------
StopIteration Traceback (most recent call last)
~/anaconda3/lib/python3.6/site-packages/peewee.py in get(self)
3219 try:
-> 3220 return next(clone.execute())
3221 except StopIteration:
playhouse/_speedups.pyx in playhouse._speedups._QueryResultWrapper.__next__()
playhouse/_speedups.pyx in playhouse._speedups._QueryResultWrapper.iterate()
StopIteration:
During handling of the above exception, another exception occurred:
TweetDoesNotExist Traceback (most recent call last)
<ipython-input-31-1934918c595d> in <module>()
----> 1 examples.export_retweet_text()
2 #retweet_text = pd.read_csv("retweet_text.csv")
~/Desktop/DS/Twitter/twitterresearch/examples.py in export_retweet_text(n)
496 database.Tweet.retweet.is_null(False)).group_by(database.Tweet.retweet)
497 for tweet in retweets:
--> 498 rt_counts[tweet.retweet.id] = tweet.retweet.retweets.count()
499 from collections import Counter
500 c = Counter(rt_counts)
~/anaconda3/lib/python3.6/site-packages/peewee.py in __get__(self, instance, instance_type)
1384 def __get__(self, instance, instance_type=None):
1385 if instance is not None:
-> 1386 return self.get_object_or_id(instance)
1387 return self.field
1388
~/anaconda3/lib/python3.6/site-packages/peewee.py in get_object_or_id(self, instance)
1375 if rel_id is not None or self.att_name in instance._obj_cache:
1376 if self.att_name not in instance._obj_cache:
-> 1377 obj = self.rel_model.get(self.field.to_field == rel_id)
1378 instance._obj_cache[self.att_name] = obj
1379 return instance._obj_cache[self.att_name]
~/anaconda3/lib/python3.6/site-packages/peewee.py in get(cls, *query, **kwargs)
4986 if kwargs:
4987 sq = sq.filter(**kwargs)
-> 4988 return sq.get()
4989
4990 @classmethod
~/anaconda3/lib/python3.6/site-packages/peewee.py in get(self)
3222 raise self.model_class.DoesNotExist(
3223 'Instance matching query does not exist:\nSQL: %s\nPARAMS: %s'
-> 3224 % self.sql())
3225
3226 def peek(self, n=1):
TweetDoesNotExist: Instance matching query does not exist:
SQL: SELECT "t1"."id", "t1"."user_id", "t1"."text", "t1"."date", "t1"."language_id", "t1"."reply_to_user_id", "t1"."reply_to_tweet", "t1"."retweet_id" FROM "tweet" AS t1 WHERE ("t1"."id" = ?)
PARAMS: [0]
Hi @Vix18, it seems your database is either empty or you are attempting to get a non-existing tweet. The interesting part are the last few lines of the output:
TweetDoesNotExist (that's the exception's name). The database looked for a tweet with ID=0 (that's the PARAMS at the end).
You could verify whether there are any tweets stored in the DB by opening an interactive python shell, importing the DB script and querying manually, i.e. along these lines:
import database
total_tweet_count = database.Tweet.select().count()
print(total_tweet_count)
etc.
Thanks - that makes sense; the database is there but I wasn't able to hydrate all of them; this function must be looking for one of the missing tweets.
Did you find/fix the error? If there is a problem replicating the basic examples from the tutorial using our dehydrated data, I'd love to know and fix that.
thanks pascale: i was able to rehydrate but not the whole set: i got up to 590000 but couldn't do more than that.
On Wed, Jun 20, 2018 at 3:53 PM, Pascal Jürgens [email protected] wrote:
Did you find/fix the error? If there is a problem replicating the basic examples from the tutorial using our dehydrated data, I'd love to know and fix that.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/trifle/twitterresearch/issues/17#issuecomment-398780432, or mute the thread https://github.com/notifications/unsubscribe-auth/AhU3AuH_nlM0xa1hOzVmiT3nd01K5BNqks5t-mIAgaJpZM4Upxti .