Skip to content

examples.export_retweet_text() is throwing a peewee error. Unsure how to debug. #17

@Vix18

Description

@Vix18

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions