On Saturday 17 May 2008 17:53:42 Eric Abrahamsen wrote:
> Hi there,
>
> I'm new to this, so please be patient if I'm a little slow... I'm
> trying to filter Article objects by a datetime field ('pubdate'),
> and expected that I would be able to do something like this:
>
> arts = sess.query(Article).filter(and_(Article.pubdate.year==year,
> Article.pubdate.month==month, Article.id==id)).one()
>
> This gives me:
> AttributeError: 'InstrumentedAttribute' object has no attribute
> 'year'
>
> Apparently methods on attributes are reserved for sqlalchemy
> internals, and I'm not working with a straight Python object, as
> I'd thought. That makes sense, but can anyone suggest a simple
> substitute for what I'm trying to do here?
it's SQL that is not working with python objects, and the column 
pubdate (associated with type DateTime on python side) has no 
attr .year or .month.

lookup the messages in the group, there were some sugestions long time 
ago, but AFAIremember one was something with strings, another with 
separate columns.

wishlist suggestion: how about type-related attributes on columns, 
using which will autogenerate some expr off that column?
e.g. select( mytable.c.mydate.year == '1998') to automagicaly yield 
something like func.substr(mytable.c.mydate,1,4)) == '1998' 
(supposing the type of mydate stores datetime as yyyymmdd string)

ciao
svil

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to