I now have a less klugey (no strings) implementation that I came to after
circling back to the the recursive CTE example in the docs, but is
structured in a way that I can wrap my head around a lot better:
import sqlalchemy as sa
#initialize a recursive CTE construct using the non-recursive
On Jul 10, 2012, at 2:04 AM, Russell Warren wrote:
As per the comments in the code, the alias is absolutely required (it gets
mangled without the alias), but is seemingly pointless in the resulting SQL.
Referring to PG's docs:
http://www.postgresql.org/docs/8.4/static/queries-with.html
On Tue, Jul 10, 2012 at 11:31 AM, Michael Bayer mike...@zzzcomputing.comwrote:
So some modifications to CTE are made in r079123b04dc6 (0.8) /
ra742d1526e86 (0.7) such that CTEs are now rendered based on name-based
logic only. A given CTE name will only be rendered as a full statement
once,
select(literal(0).alias(x)) should do it, see the documentation at ...
Thanks... literal() gave me a location on which to attach a label I
can reference. I'm closer, but still can't get this to work.
Here's my closest so far (iwth SQLAlchemy 0.7.8):
import sqlalchemy as sa
#set up the
First off, there's a bug with CTE + union in 0.7.8 and earlier. Get 0.7.9
from the hg tip linked on the download page.
Next, maybe try calling cte() *after* you've done
select(...).union_all(otherselect()). Not sure if that will do it though.
On Jul 9, 2012, at 9:41 PM, Russ wrote:
On Mon, Jul 9, 2012 at 9:53 PM, Michael Bayer mike...@zzzcomputing.comwrote:
First off, there's a bug with CTE + union in 0.7.8 and earlier. Get
0.7.9 from the hg tip linked on the download page.
Next, maybe try calling cte() *after* you've done
select(...).union_all(otherselect()). Not