On Thu, Oct 9, 2008 at 9:01 PM, John Hunter <[EMAIL PROTECTED]> wrote:

>> if the attribute is "attached" to either PriceData or FundamentalData,
>> the general route towards this kind of thing is to use
>> column_property().   You can place subqueries which correlate to the
>> base table in those.   If you're looking for a third mapped object
>> along the lines of RatioData, you can map such a class to a select()
>> object which represents the query, although this seems more like an
>> attribute on PriceData.
>>
>> the column_property() is usable in queries and you can also customize
>> how it compares using a user-defined PropComparator.
>>
>> a brief example is at:  
>> http://www.sqlalchemy.org/docs/05/mappers.html#advdatamapping_mapper_expressions

Here's another question: I have to compute several of these
price/something ratios.  For performance, it seems like it would be
best to do them all in a single select, eg

   price_sales , price_income=  orm.column_property(
      sa.select(
         [price/FundamentalData.sales, price/FundamentalData.income],
         (ticker==FundamentalData.ticker) & (date>=FundamentalData.reportdate),
            ).order_by(FundamentalData.reportdate.desc()).limit(1))

but doesn't appear to be allowed,

  InvalidRequestError: Scalar select can only be created from a Select
object that has exactly one column expression.
  WARNING: Failure executing file: <sqlalchemy_demo.py>

Is there a way to do several of these at once?

Thanks again,
JDH

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to