Re: [sqlalchemy] ORM Different SELECT/INSERT Tables

2014-06-18 Thread Michael Weylandt
My use case is a simple CRUD app which has a history table (patterned on the example in the SQLAlchemy docs) and a "current" table. I want to write a simple context manager so that f = db.session.query(Foo).all() gives current values while: with app.as_of(date(2014, 05, 31)): f = db.sess

Re: [sqlalchemy] ORM Different SELECT/INSERT Tables

2014-06-18 Thread Mike Bayer
Mapper has a _set_with_polymorphic() method that will do this. Though I'm looking at your original use case, that is you want to select from a view, and I'm not really sure why you need to set it on the outside. Persist to a table select from a view would look like: the_view = Table('the_view'

Re: [sqlalchemy] ORM Different SELECT/INSERT Tables

2014-06-18 Thread Michael Weylandt
Bumping this, is there a way to do a "replacement" with_polymorphic instead of an "addition"? Michael On Tuesday, April 8, 2014 3:59:34 PM UTC-4, Michael Weylandt wrote: > > On Monday, April 7, 2014 5:11:48 PM UTC-4, Michael Bayer wrote: >> >> >> On Apr 7, 2014, at 2:46 PM, Michael Weylandt >

Re: [sqlalchemy] ORM Different SELECT/INSERT Tables

2014-04-08 Thread Michael Weylandt
On Monday, April 7, 2014 5:11:48 PM UTC-4, Michael Bayer wrote: > > > On Apr 7, 2014, at 2:46 PM, Michael Weylandt > > > wrote: > > > Since the logic creating the view is a little hairy, I'd like to avoid > replicating it in Python and just > > have SQLAlchemy redirect all SELECT statements to

Re: [sqlalchemy] ORM Different SELECT/INSERT Tables

2014-04-07 Thread Michael Bayer
On Apr 7, 2014, at 2:46 PM, Michael Weylandt wrote: > Is it possible to have SQLAlchemy use different tables for SELECT and INSERT > statements? > > I'm using the Declarative/ORM setup with Flask-SQLAlchemy and I am faced with > a very large table > and a view which shows a subset of that ta

[sqlalchemy] ORM Different SELECT/INSERT Tables

2014-04-07 Thread Michael Weylandt
Is it possible to have SQLAlchemy use different tables for SELECT and INSERT statements? I'm using the Declarative/ORM setup with Flask-SQLAlchemy and I am faced with a very large table and a view which shows a subset of that table. Since the logic creating the view is a little hairy, I'd lik