I'm trying to extend SQLA with a construct for using SQL Server's PIVOT 
functionality. I've written a class and a @compiles function to generate 
the query for this and this produces the correct query (e.g., given a 
sqlalchemy.Table and some Column objects it produces the right query).

My problem is that the return type is a string, not a 
sqlalchemy.sql.expression.Select like object, so I can't do something like 

x = Pivot(table.c.key_col, table.c.pivot_col, ['attribute1, 'attribute2'], 
from_query)
y = sqlalchemy.select([x.c.attribute1])

After Googling around I really couldn't find any examples like this. The 
examples on the documentation page seem to also just produce strings (and 
are Executable rather than "Selectable" anyway).  (Mainly 
http://www.sqlalchemy.org/trac/wiki/UsageRecipes and 
http://docs.sqlalchemy.org/en/rel_0_7/core/compiler.html)

Anyone have some tips on how to make the above do-able? An explanation for 
how to produce any kind of custom select statement (that could then be 
selected from) would be fine. Or if this isn't possible currently please 
let me know.

Thanks,
Dan

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to