> 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 non-recursive part of the query (sort of?)...
cte = sa.select(
    [sa.literal(0).label("x"), ]
    ).cte(name = "cte", recursive = True)
#bring in the recursive part (sort of?)...
cte = cte.union_all(
    sa.select([cte.c.x + 1, ]).\
    where(cte.c.x < 10)
)
#select from the resulting CTE...
statement = sa.select([cte.c.x, ])
print statement

which yields...

WITH RECURSIVE cte(x) AS
(SELECT :param_1 AS x),
cte(x) AS
(SELECT :param_1 AS x UNION ALL SELECT cte.x + :x_1 AS anon_1
FROM cte
WHERE cte.x < :x_2)
 SELECT cte.x
FROM cte

which isn't right at all, and is confusing to me.  Especially where
the UNION ALL ended up and that the CTE wrapping brackets are totally
wrong.

I'll keep at it.  It is hard to assemble this piece by piece and check
as I go since adding the .cte seems to prevent printing of progress
until the very end.

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to