Re: Dreaming About Redesigning SQL

From: Patrick K. O'Brien <pobrien_at_orbtech.com>
Date: 13 Oct 2003 13:08:37 -0500
Message-ID: <m2ad856me2.fsf_at_orbtech.com>


alfredo_at_ncs.es (Alfredo Novoa) writes:

> pobrien_at_orbtech.com (Patrick K. O'Brien) wrote in message news:<m2pth33gj6.fsf_at_orbtech.com>...
>
> > > Lauri was not talking about trivial queries like "select * from A"
> >
> > Lauri made a blanket statement. I made a clarifying statement. I
> > can think of lots of trivial examples of a "standard SQL-query
> > with sorting and grouping and some joins." The "equivalent
> > result" in Python would not "require several pages of hand written
> > code." I stand by my original statement.
>
> It is false. A simple SQL query with several joins, extensions and a
> summarize would be equivalent to several pages of error prone and
> tedious hand written code, and of course the oportunities for
> optimization are lost.

    group = {}
    for od in db.root['OrderDetail']:

        key = (od.order.customer.name, od.product.name)
        subtotal = od.quantity * od.product.price
        group[key] = group.get(key, 0) + subtotal
    totals = [(t, c, p) for ((c, p), t) in group.items()]     totals.sort()
    return totals

This is the code that satisfies Lauri's example. It doesn't look like several pages of error prone and tedious hand written code to me. So who is making false statements?

-- 
Patrick K. O'Brien
Orbtech      http://www.orbtech.com/web/pobrien
-----------------------------------------------
"Your source for Python programming expertise."
-----------------------------------------------
Received on Mon Oct 13 2003 - 20:08:37 CEST

Original text of this message