Re: [sqlalchemy] SQLAlchemy orm attribute post-update hook?

2013-11-28 Thread Amir Elaguizy
What do you think about the pattern I've implemented for this purpose using metaclasses? https://gist.github.com/aelaguiz/7691751 I've also pasted the code here but it's nicer to look at on github via the link above: import logging import sqlalchemy as sqla import sqlalchemy.ext.declarative

Re: [sqlalchemy] SQLAlchemy orm attribute post-update hook?

2013-11-28 Thread Michael Bayer
if it works, that’s fine. as far as metaclasses I like to recommend using SQLAlchemy class instrumentation events instead so that there’s no complication re: declarative’s own metaclass and such. On Nov 28, 2013, at 8:24 AM, Amir Elaguizy aelag...@gmail.com wrote: What do you think about

Re: [sqlalchemy] How to do datetime arithmetic in Column()?

2013-11-28 Thread Michael Bayer
SQLAlchemy doesn’t yet have date arithmetic functions built in to the point that we abstract away the underlying database features. Date arithmetic currently relies on the end-user implementing the SQL using exactly the functions that the target database expects. These vary completely on all

Re: [sqlalchemy] creating a cte from a string and some params

2013-11-28 Thread Chris Withers
Hi Mike, Happy Thanksgiving :-) On 22/11/2013 15:55, Michael Bayer wrote: I don't *need* to ;-) ...but I was wondering how, starting with a raw string and a couple of variables to bind in, I could get a cte that I could join against an ORM-mapped object? uh well we don’t exactly have

Re: [sqlalchemy] creating a cte from a string and some params

2013-11-28 Thread Michael Bayer
On Nov 28, 2013, at 7:54 PM, Chris Withers ch...@simplistix.co.uk wrote: So far, I got: inst = aliased(Part) unit = aliased(Part) query = session.query( inst.idea_id, inst.instrument_id, func.sum(inst.quantity),