Thank you Michael, I think sometimes I am blind xD

Regards

El miércoles, 15 de abril de 2015, 15:13:38 (UTC+2), Michael Bayer escribió:
>
>  
>
> On 4/15/15 6:52 AM, Juan Antonio Ibáñez wrote:
>  
> Hello, 
>
>     I have dozens of queries filtering DateTime columns but I have got 
> one I don't know why it doesn't work. I have:
>
>  ---------------------------
>  q = DBSession.query(func.sum(RecargaCredito.importe), Local.nombre)\
>     .join((Local, RecargaCredito.locales_id == Local.id))
>
>  fl_desde = (datetime.now() - timedelta(days=7)).replace(hour=0, 
> minute=0, second=0)
> fl_hasta = datetime.now().replace(hour=23, minute=59, second=59)
>
>  q = q.filter(RecargaCredito.fechayhora >= fl_desde).\
>     filter(RecargaCredito.fechayhora <= fl_hasta)
>
>  q = q.group_by(RecargaCredito.locales_id)
>
>  f = q.all()
>  ---------------------------
>
>  
>  RecargaCredito looks:
>
>  
>  ---------------------------
> class RecargaCredito(DeclarativeBase):
>     __tablename__ = 'recargas_credito'
>     __table_args__ = {'mysql_engine':'InnoDB'}
>
>      id=Column(Integer, primary_key=True)
>     fechayhora = DateTime
>     importe = Column(DECIMAL(9,2))
>     locales_id=Column(Integer, ForeignKey('locales.id'))
>     
>     local = relation('Local', remote_side = 'Local.id')
>  ---------------------------
>  
>  and I get error 'TypeError: can't compare datetime.datetime to 
> VisitableType'
>  
>
> you seem to be missing "Column()" for fechayhora:
>
> fechayhora  = Column(DateTime)
>
>
>
>
>  
>  I've checked fl_desde and fl_hasta are python datetime objects
>
>  Do you know what that error says?
>  
>  Regards
>
>  
>  -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] <javascript:>.
> To post to this group, send email to [email protected] 
> <javascript:>.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.
>
>
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to