[sqlalchemy] How to do date calculations in a query and in relations?

2008-02-16 Thread Thomas Wittek
Hi! I'm trying to filter my data by some date calculations. In detail, I want to filter out messages that have been marked as deleted more than 30 days ago. In a query I could do it like this: threshold = datetime.now() - datetime.timedelta(30) return

[sqlalchemy] Re: Has anyone implemented a dict of lists collection_class?

2008-02-16 Thread Michael Bayer
oh, heres a second version that fixes list.__setitem__. the operations here are not terribly efficient but you could build better caching scenarios if needed. from sqlalchemy import * from sqlalchemy.orm import * metadata = MetaData() objects = Table('objects', metadata, Column('id',

[sqlalchemy] Re: Has anyone implemented a dict of lists collection_class?

2008-02-16 Thread Michael Bayer
yet another adjustment to ListAdapter... class ListAdapter(object): def __init__(self, parent, key): self.__parent = parent self.__key = key def __cached(self): try: return self.__cached_data except AttributeError:

[sqlalchemy] Re: Has anyone implemented a dict of lists collection_class?

2008-02-16 Thread Michael Bayer
also, it would take a lot more experimentation but maybe the @appender and @remover methods could be useful here, just so that the cached view of the data can be maintained as the data is retrieved from the DB.Maybe its just my thought process (also since i didnt write the collections

[sqlalchemy] Re: Has anyone implemented a dict of lists collection_class?

2008-02-16 Thread Eric Ongerth
It occurs to me that a near analogue to this would be... storing a collection of one man's children by different mothers. While it's somewhat useful to have a collection of the guy's children... what if you want to look up his children by just one mother, or by each mother in turn. There's an

[sqlalchemy] Re: update sequence on insert

2008-02-16 Thread Brett
I have to be able to dump my tables to CSV so I need to keep the primary key values so my foreign keys match up. Michael Bayer wrote: On Feb 15, 2008, at 5:53 PM, Brett wrote: serial column instead. On sqlite the id column seems to always generate a unique number. I'm not sure what

[sqlalchemy] Re: update sequence on insert

2008-02-16 Thread Michael Bayer
On Feb 16, 2008, at 8:31 PM, Brett wrote: I have to be able to dump my tables to CSV so I need to keep the primary key values so my foreign keys match up. Michael Bayer wrote: On Feb 15, 2008, at 5:53 PM, Brett wrote: serial column instead. On sqlite the id column seems to always