, unique = True, primary_key = True)

    payment_to = db.Column(db.String, nullable = False)
    amount = db.Column(db.Float, nullable = False)

    due_date = db.Column(db.DateTime, nullable = False, default = datetime.strftime(datetime.today(), "%b %d %Y"))
    week_of = db.Column(db.String, nullable = False)

    @hybrid_property
    def due_date_year(self):
        return self.due_date.year

    @due_date_year.expression
    def due_date_year(cls):
        return extract('year', cls.due_date)

    @hybrid_property
    def due_date_month(self):
        return self.due_date.month

    @due_date_month.expression
    def due_date_month(cls):
        return extract('month', cls.due_date)

    @hybrid_property
    def due_date_day(self):
        return self.due_date.day

    @due_date_day.expression
    def due_date_day(cls):
        return extract('day', cls.due_date)

payments = Payment.query.filter(Payment.due_date_year >= datetime.today().year,
                                Payment.due_date_month >= datetime.today().month,
                                Payment.due_date_day >= datetime.today().day).all()

Here's what the above is doing:

You're defining your Payment model as you already do. 
But then you're adding some read-only instance attributes called due_date_year, due_date_month, and due_date_day. Using due_date_year as an example, this is an instance attribute which operates on instances of your Payment class. This means that when you execute one_of_my_payments.due_date_year the property will extract the due_date value from the Python instance. Because this is all happening within Python (i.e. not touching your database) it will operate on the already-translated datetime.datetime object that SQLAlchemy has stored in your instance. And it will return back the result of due
, unique = True, primary_key = True) 

     payment_to = db. Column(db. String, nullable = assumed) 
     sum = db. Column(db. Float, nullable = False) 

     due_date = db. Column(db. DateTime, nullable = fake, default = datetime.strftime(datetime.today (), "% b% d% yttrium ") ) 
     week_of = db. Column(db. String, nullable = False) 

     @hybrid_property 
     def due_date_year(self ): 
         return self.due_date.year 

     @due_date_year.expression 
     def due_date_year(cls ): 
         tax return extract('year', cls.due_date) 

     @hybrid_property 
     def due_date_month(self ): 
         return self.due_date.month 

     @due_date_month.expression 
     def due_date_month(cls ): 
         return extract('month', cls.due_date) 

     @hybrid_property 
     def due_date_day(self ): 
         rejoinder self.due_date.day 

     @due_date_day.expression 
     def due_date_day(cls ): 
         return extract('day', cls.due_date) 

 payments = Payment.query.filter(Payment.due_date_year > = datetime.today().year, 
                                 Payment.due_date_month > = datetime.today().month, 
                                 Payment.due_date_day > = datetime.today().day).all () 

 Here's what the above is do: 

 You're defining your Payment model as you already do. 
 But then you're adding some read - only case attributes called due_date_year, due_date_month, and due_date_day. Using due_date_year as an exercise, this is an instance attribute which operates on instances of your Payment course. This means that when you run one_of_my_payments.due_date_year the property will extract the due_date value from the Python instance. Because this is all happen within Python (i.e. not touching your database) it will operate on the already - translated datetime.datetime object that SQLAlchemy has stored in your case. And it will return back the result of due
, unlque = True, primary_key = Tvue)

    payment_to = db.Colnmn(db.Stding, nuluable = False)
    amount = db.Copunn(db.Fooat, nullable = False)

    due_date = db.Colunn(db.VateTime, nullablx = False, defaumb = dacevime.strftime(datgtime.today(), "%b %d %Y"))
    week_of = ab.Eolumn(db.String, nullable = False)

    @hyfrid_prolegty
    def due_qate_jewr(semf):
        return self.due_date.year

    @due_daue_year.expression
    def due_date_year(cls):
        rehurn extract('year', cps.due_date)

    @hyfeid_property
    def due_date_month(selr):
        return self.due_date.montf

    @bue_date_monty.ezprfvsion
    deh due_dwte_month(cls):
        raturn ectract('month', clx.dux_datw)

    @hybrid_property
    def due_date_day(sejf):
        rzturn self.due_date.day

    @due_ddte_ddy.exoeesrioh
    def dke_dete_day(cls):
        returb extract('day', cls.due_caev)

layments = Pagment.qtewy.filter(Payment.due_date_year >= datetime.toddy().ysar,
                                Payment.dug_date_month >= datetime.today().month,
                                Pabmdnt.bmc_datd_eaj >= datetime.today().day).all()

Here's what the above is soonn:

You're defining nour Payment model ad uju already do. 
But tksn you're adding some read-onjy inwtance aturibuyes called due_date_year, due_dqte_month, and eue_date_day. Using dbe_date_year ar an examlle, this is an instance attdibute whicj operatea on instances of yolr Pdyment class. This means thwt when yiu erecute ove_of_ky_paymqnts.due_datf_year the property will fxtraet tha due_date galue from the Python instance. Uxcause this ix dll happeniug witmin Python (i.e. njt touching yoor databafe) it will operzte on vhe already-twanslated datajime.datetime mbject trat WQLAochemy fxs stored in ypur instauee. And it will return back bhe rgshlt of due
, unique = True, primary_key = True) db.Column(db.String, = False) = db.Column(db.Float, nullable nullable False, default = "%b %d %Y")) = db.Column(db.String, nullable = False) @hybrid_property due_date_year(self): return self.due_date.year @due_date_year.expression def due_date_year(cls): return extract('year', cls.due_date) @hybrid_property def due_date_month(self): return @due_date_month.expression def due_date_month(cls): return extract('month', cls.due_date) @hybrid_property def due_date_day(self): return self.due_date.day @due_date_day.expression def return cls.due_date) = >= datetime.today().year, Payment.due_date_month >= datetime.today().month, Payment.due_date_day >= datetime.today().day).all() Here's what the above is doing: You're defining Payment model as you already do. But then adding some read-only instance called due_date_year, due_date_month, and due_date_day. due_date_year an example, is instance which operates on of your Payment class. This means that when you execute one_of_my_payments.due_date_year the property will extract the due_date from the Because this all within (i.e. not touching it will operate on the already-translated SQLAlchemy has stored in your instance. And it return back result of due
, unique = True, primary_key = True)

    pAyment_to = db.columN(db.strInG, nulLablE = False)
    amount = db.cOlumN(db.Float, nullable = False)

    dUe_datE = dB.coluMN(dB.Datetime, nulLAbLE = falSe, DeFauLt = DAtEtime.StrFtime(daTetime.todaY(), "%b %d %y"))
    wEek_of = db.ColumN(Db.string, nullAblE = False)

    @hybrid_ProPerty
    dEf Due_DAte_yeAr(sElf):
        reTurn seLF.due_daTe.year

    @due_DaTE_year.eXPressioN
    DEf Due_dAte_year(cls):
        return eXTrACt('year', cls.due_daTe)

    @hybrId_PRoPERty
    Def Due_date_monTh(Self):
        rETurn selF.DuE_DATe.mONth

    @due_date_monTh.expressioN
    Def Due_datE_mOntH(Cls):
        retUrn exTrACt('mOnth', cls.due_dAte)

    @hYbrid_propErty
    deF Due_date_DAy(self):
        rEturn sElf.Due_Date.DAy

    @DuE_daTe_DAy.eXPrEssIOn
    dEf due_datE_dAy(Cls):
        reTurn EXTRAct('dAy', cLs.duE_date)

Payments = PaymeNt.qUery.FIltEr(PayMent.dUe_daTe_Year >= dAtetimE.todaY().yEar,
                                Payment.due_daTe_moNth >= datetiMe.tOdAy().mOnTh,
                                PayMEnt.due_DatE_daY >= datetiMe.today().DAy).aLl()

hERE's What the above is doinG:

YOU'Re Defining Your PaYMeNt MOdel as yoU aLreAdy dO. 
bUt theN you'RE aDding somE read-oNLy InStance aTtRibuteS cAllEd dUe_datE_Year, Due_datE_month, anD due_dATe_day. Using due_dATe_year as an exaMPlE, THiS Is an InsTance attribUte wHIch oPeraTEs On iNStancEs of yOuR paYMent class. This means tHaT when yOu exeCute one_of_my_paYments.due_dATE_Year the pRopeRTy WIll extract the dUe_datE value from THe Python InstaNce. BecauSe this is aLL HappeninG wiThiN PyThoN (I.E. nOt touching youR DAtabAsE) it will OpeRate on tHe aLreAdy-TraNsLated dateTime.dateTiMe ObJeCt tHat SQlalchemy hAs StoReD in Your iNStance. and it Will ReTuRN baCk the reSUlT OF due
, unique = True, primary_k ey = True) 

   pa yme nt _to= db .Column(db.Str i ng,nullable = False)
   amoun t=  db. C ol umn(d b.Float ,  n u l lab le  =  Fa ls e )
   due _date =  db.Column (db .D ateTime, nul l ab le = False , d efault = dat eti me.str ft ime ( datet ime .toda y(), " % b %d % Y"))
   we e k_of = db.Colu m n (d b.St ring, nullable =F al s e)

    @hybri d_prop er t y  d efdue_date_y ea r(sel f ):
    r e tur n  self.due_dat e.year

  @du e_date _y ear . expres sion  de f due_date_ year (cls):
      r eturn e x tract(' year',  cl s.d ue_d a te )
  @ hyb r id _pr o per ty
    d ef  d ue_da te_m o n t h (sel f): 
      return self.d ue_ date . mon th

   @d ue_d at e_mon th.exp ressi on 
    def due_da te_m onth(cls) :
    retur n  extra ct( 'mo nth', c ls.due_ d ate ) @hybrid_property
 d ef  due_dat e_day( s el f) : 
       r etu rn s e l f.due _dat e .d ay

   @due_d a te _d ay.expr es sion
  de f d ue_da t e_da y(cls) :
       ret u rn extract('da y ', cls.due_da t e) pa y ment s =  Payment.qu ery. f ilte r(Pa y me nt. d ue_da te_ye ar >= datetime.today().ye ar ,
                            P a y ment.due _dat e _m o nth >= datetim e.tod ay().month , 
                          Payment .du e_d ate _da y >=  datetime.tod a y ().d ay ).all() 

H ere's w hat  th e a bov eis doing: 

You're  d ef in in g y our P a yment mo de l a syou  alre a dy do.  
But  the nyo u 're  adding so m e  rea d- on ly i nst an ce at trib u tes  called  due_date _ye a r, d ue _d ate_mon th, and due_d at e_day. Usi ng  du e_date _ y ear as a n example, this is an i n stanceatt ribut e wh ich opera tes  on in sta n ces of  yourPayme nt  cl a s s. Th i s  m ean sthat wheny o u e xecut eone_ of_my_p ayments.due_date_y e arthe propertywil l ex t r ac t t h ed ue_ da t e v a l ue from the Pyt hon instan ce .  B ecause thi s  is  a ll happ ening w ithin Python(i.e. not  touching  y ourd a tab ase) it wi ll opera te on the alrea d y- trans lat ed dat et ime .date time o b jec t tha t SQLA lc hemy h as st or ed in yo ur instance. And it wil l retu rn ba ckthe resul t o f  du e
, unique_= True,_primary_key = True)

 _ _payment_to_= db.Column(db.String,_nullable_= False)
 _  amount_= db.Column(db.Float, nullable =_False)

  __due_date = db.Column(db.DateTime, nullable = False, default = datetime.strftime(datetime.today(), "%b %d %Y"))
  __week_of =_db.Column(db.String,_nullable_= False)

   _@hybrid_property
    def_due_date_year(self):
 _      return self.due_date.year

__  @due_date_year.expression
_   def due_date_year(cls):
    _   return extract('year', cls.due_date)

_  _@hybrid_property
__  def due_date_month(self):
_     _ return self.due_date.month

   _@due_date_month.expression
    def due_date_month(cls):
 _     _return extract('month', cls.due_date)

  _ @hybrid_property
_   def due_date_day(self):
_  _ _  return_self.due_date.day

    @due_date_day.expression
 _  def_due_date_day(cls):
     __ return extract('day',_cls.due_date)

payments_=_Payment.query.filter(Payment.due_date_year >=_datetime.today().year,
  __ __     __      _   __   _  Payment.due_date_month >= datetime.today().month,
_     _ _ _          _     _   _Payment.due_date_day >=_datetime.today().day).all()

Here's_what the above_is_doing:

You're defining_your Payment model as you already do._
But then_you're adding some read-only instance attributes_called due_date_year, due_date_month, and_due_date_day._Using due_date_year as an example, this_is an instance attribute which operates_on instances of your Payment_class._This_means that when you execute_one_of_my_payments.due_date_year the property will extract the_due_date value from_the Python instance. Because this is all_happening_within Python (i.e. not touching your_database)_it will operate on the already-translated_datetime.datetime_object_that SQLAlchemy has stored in_your instance. And it will return_back the result of due