[sqlalchemy] Making ResultProxy test as False when there are no rows

2011-10-14 Thread Lloyd Kvam
Would it make sense to add a __nonzero__ method to ResultProxy that was tied to the rowcount? def __nonzero__(self): return bool(self.rowcount) This would allow code like if results: process(results) I was surprised when this did not work. -- You received this message because you are

Re: [sqlalchemy] passing parameters to subquery in mapped select

2011-10-14 Thread Michael Bayer
On Oct 14, 2011, at 10:56 AM, Burak Arslan wrote: On 10/14/11 06:40, Michael Bayer wrote: its a little awkward but if you use bindparam() in the inner select, query.params() can access those parameters just fine, you'd just need to use it in all cases. there's some related example of

Re: [sqlalchemy] Making ResultProxy test as False when there are no rows

2011-10-14 Thread Michael Bayer
On Oct 14, 2011, at 10:38 AM, Lloyd Kvam wrote: Would it make sense to add a __nonzero__ method to ResultProxy that was tied to the rowcount? def __nonzero__(self): return bool(self.rowcount) This would allow code like if results: process(results) I was surprised when this

Re: [sqlalchemy] passing parameters to subquery in mapped select

2011-10-14 Thread Burak Arslan
On 10/14/11 18:01, Michael Bayer wrote: On Oct 14, 2011, at 10:56 AM, Burak Arslan wrote: On 10/14/11 06:40, Michael Bayer wrote: its a little awkward but if you use bindparam() in the inner select, query.params() can access those parameters just fine, you'd just need to use it in all

[sqlalchemy] Re: Making ResultProxy test as False when there are no rows

2011-10-14 Thread Lloyd Kvam
On Oct 14, 11:02 am, Michael Bayer mike...@zzzcomputing.com wrote: On Oct 14, 2011, at 10:38 AM, Lloyd Kvam wrote: Would it make sense to add a __nonzero__ method to ResultProxy that was tied to the rowcount? def __nonzero__(self):    return bool(self.rowcount) This would allow

[sqlalchemy] can't find a way to index field with orm.

2011-10-14 Thread Krishnakant Mane
Hello all, I feel I am seriously missing some point here. suppose I am creating a class representing a table through orm. I will asume that it is using declarative syntax. I wish to know how do we index a field? that is to say, I need to have indexes on a few fields so that they are applied to

[sqlalchemy] IS DISTINCT FROM

2011-10-14 Thread Jon Nelson
What is the SA equivalent of: UPDATE foo SET bar=some_function(baz) WHERE bar IS DISTINCT FROM some_function(baz) I get this far (assuming 't' is a Table instance): t.update().values(t.c.bar=sa.func.some_function(t.c.baz).where( ... what do I put here ) IS DISTINCT FROM (and IS NOT

[sqlalchemy] Re: IS DISTINCT FROM

2011-10-14 Thread Jon Nelson
On Fri, Oct 14, 2011 at 4:45 PM, Jon Nelson jnel...@jamponi.net wrote: What is the SA equivalent of: UPDATE foo SET bar=some_function(baz) WHERE bar IS DISTINCT FROM some_function(baz) I get this far (assuming 't' is a Table instance):

Re: [sqlalchemy] Re: IS DISTINCT FROM

2011-10-14 Thread Michael Bayer
for now yes, I've not heard of IS DISTINCT FROM before. On Oct 14, 2011, at 6:25 PM, Jon Nelson wrote: On Fri, Oct 14, 2011 at 4:45 PM, Jon Nelson jnel...@jamponi.net wrote: What is the SA equivalent of: UPDATE foo SET bar=some_function(baz) WHERE bar IS DISTINCT FROM some_function(baz)

Re: [sqlalchemy] Re: IS DISTINCT FROM

2011-10-14 Thread Jon Nelson
On Fri, Oct 14, 2011 at 8:12 PM, Michael Bayer mike...@zzzcomputing.com wrote: for now yes, I've not heard of IS DISTINCT FROM before. In the right places, it's mighty useful. -- Jon -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to

[sqlalchemy] Degenerate relationship?

2011-10-14 Thread Mark Erbaugh
There are two tables pump and curve. The curve table has three fields, curve_pn, head and gpm. The design is that the rows with the same curve_pn value represent x,y points (head,gpm) on a pump performance curve. Each row in the pump table has a curve_pn column that links to the performance