Try basing the interval query on a correlated subquery, so instead of
q = session.query(
column,
func.row_number().\
over(order_by=column).\
label('rownum')
).\
from_self(column)
Try basing the interval query on a correlated subquery, so instead of
q = session.query(
column,
func.row_number().\
over(order_by=column).\
label('rownum')
).\
from_self(column)
Can do one better by just passing the filter expression.
table_filter = Widget.id 5000
passing table_filter as an optional parameter to column_windows, the
interval query becomes
q = session.query(
column,
func.row_number().\
For nesting the joins you have to use the join() construct manually, your
example is pretty verbose there, here's a shorter example.Note that
SQLAlchemy has two join() functions - one is sqlalchemy.sql.join, the other
is sqlalchemy.orm.join. The main thing you get from orm.join is that you
On Aug 10, 2014, at 2:52 PM, alchemy1 veerukrish...@hotmail.com wrote:
I see that in ForeignKey I can use either a string or reference, so
ForeignKey(MyModel.id) or ForeignKey('my_model.id'). Any advantage to using
one or the other? What's the recommended approach?
whichever one is more
I've got the expression part of the hybrid properties working now, using an
alias:
@friend_code_usage_count.expression
def friend_code_usage_count(cls):
alias = aliased(AffinionCode)
return select([func.count(alias.Rtid)]). \
where(alias.PromoCode ==
I do have a follow up, actually.
If I wanted to make friend_code_usage_count a column property so that it
was always loaded with the object, how would I do that?
It doesn't look like I can add
alias = aliased(AffinionCode)
within the class definition. Where/how would I define the alias?
For a fancy column_property like that you likely need to define it after
the fact and attach it to the class. There's some new features I have
in the works for 1.0 to make that easier.
The general idea is:
class MyClass(Base):
# ...
alias = aliased(MyClass)
stmt =
cool, thanks again.
On Monday, August 11, 2014 1:19:30 PM UTC-5, Michael Bayer wrote:
For a fancy column_property like that you likely need to define it after
the fact and attach it to the class. There's some new features I have in
the works for 1.0 to make that easier.
The general
I have combined several examples I've found to try to get the
'transactional-style' of unit tests to work, where you roll back the
database after each test. However when I run this, the test fails when
trying to insert the object with DBSession.add, complaining that the tables
don't exist. I
On 08/11/2014 04:37 PM, alchemy1 wrote:
I have combined several examples I've found to try to get the
'transactional-style' of unit tests to work, where you roll back the
database after each test. However when I run this, the test fails when
trying to insert the object with DBSession.add,
11 matches
Mail list logo