Seth wrote:
>
> Michael,
>
> This is not valid SQL being outputted (at least on SQLite & MySQL).
> There should not be a parenthesis between the first UNION and SELECT.
> This causes an SQL error.
>
> Is there a way to reformat the query to get valid SQL?
the results you posted do not have any parenthesis, so I don't know what
you're referring to.
Here is an independent test which also does not render any parenthesis:
from sqlalchemy import *
from sqlalchemy.orm import *
m = MetaData()
t = Table('t1', m,
Column('id', Integer, primary_key=True),
Column('data', String)
)
class C(object):
pass
mapper(C, t)
s = create_session()
q = s.query(C.id, C.data).from_statement(t.select().union(t.select()))
print q
SELECT t1.id, t1.data
FROM t1 UNION SELECT t1.id, t1.data
FROM t1
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---