2 # Django # SQL Alchemy --> better idea? Entry.objects.filter(pub_date__year=2019) Entry.query.filter( Entry.pub_date >= datetime.date(2019, 1, 1), Entry.pub_date <= datetime.date(2019, 12, 31)).all() # Get records from Monday only (1=Sunday) Entry.objects.filter(pub_date__week_day=2) # TODO: ? # Get records made at 2:30pm Entry.objects.filter(pub_date__time=datetime.time(14, 30)) # TODO: ? #### 3 # Starts with “What” and were published after January 1 # Django # SQL Alchemy ----> how to be >= 2019, 1, 1? Entry.objects.filter( Entry.query.filter( headline__startswith='What' Entry.headline.like('What%') ).filter( ).filter( pub_date__gte=datetime.date(2019, 1, 1) Entry.pub_date >= datetime.date(2019, 1, 1) ) ).all() #### 4 # Starts with “What” and were published between January 1, and the current day # Django # SQL Alchemy Entry.objects.filter( Entry.query.filter( headline__startswith='What' Entry.headline.like('What%') ).exclude( .filter( pub_date__gte=datetime.date.today() ~(Entry.pub_date >= datetime.date.today()) ).filter( ).filter( pub_date__gte=datetime.date(2019, 1, 1) Entry.pub_date >= datetime.date(2019, 1, 1) ) ).all()
models.CharField(max_length=32) country = models.ForeignKey(Country) population = models.PositiveIntegerField() metadata = jsonfield.JSONField(default={})