Need a little assistance in this last query condition syntax.
        now = datetime.now()
        h = 72
        seconds = h*3600
        if not self.reg_time or (now-self.reg_time).total_seconds() <
seconds and self.enabled==True:
            sqlstr = """ select sum(happen_amount) from cash_journal
                         where transaction_type in ('s','l','p')
                           and extract(epoch from
(:now-happen_time))<:seconds
                           and distributor_id = :id
           lockAmount = engine.execute(text(sqlstr), now=now,
seconds=seconds, id=self.id).scalar()

So for I have everything converted except "and extract(epoch from
(:now-happen_time))<:seconds"

        now = datetime.datetime.now()
        h = 72 # Need to pull this from database
        seconds = h * 3600
        payback_types = ['s','p']
        if not distributor.reg_time or (now -
distributor.reg_time).total_seconds() < seconds and distributor.enabled ==
True:
            payback_types.append('l')

        happen_sum = self.db.cash_journal.happen_amount.sum()
        rows = self.db((self.db.cash_journal.distributor_id ==
distributor.id) & \

 
(self.db.cash_journal.transaction_type.belongs(payback_types))).select(self.db.cash_journal.happen_amount.sum())

How would I do add this condition to the above rows query: "and
extract(epoch from (:now-happen_time))<:seconds"
-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com

Reply via email to