How can I execute a query like if I'm using the normal python DB API,
passing params as a sequence and not as a mapping?
Something like:
myParams = (1, 1, 2, 51, 3, 101, 4, 151, 6, 201, 7, 251)
Session.execute("""
SELECT T.datetime, MAX(T.v0), MAX(T.v1), MAX(T.v2), MAX(T.v3),
MAX(T.v4), MAX(T.v5) FROM (
SELECT data.value AS v0, NULL AS v1, NULL AS v2, NULL AS v3,
NULL AS v4, NULL AS v5
FROM acquisitions INNER JOIN data
ON acquisitions.id = data.id_acq
WHERE acquisitions.id_centr=? and dati.id_mis=?
UNION
SELECT NULL AS v0, data.value AS v1, NULL AS v2, NULL AS v3,
NULL AS v4, NULL AS v5
FROM acquisitions INNER JOIN data
ON acquisitions.id = data.id_acq
WHERE acquisitions.id_centr=? and dati.id_mis=?
UNION
SELECT NULL AS v0, NULL AS v1, data.value AS v2, NULL AS
v3, NULL AS v4, NULL AS v5
FROM acquisitions INNER JOIN data
ON acquisitions.id = data.id_acq WHERE
acquisitions.id_centr=? and dati.id_mis=?
UNION
SELECT NULL AS v0, NULL AS v1, NULL AS v2, data.value AS
v3, NULL AS v4, NULL AS v5
FROM acquisitions INNER JOIN data
ON acquisitions.id = data.id_acq
WHERE acquisitions.id_centr=? and dati.id_mis=?
UNION
SELECT NULL AS v0, NULL AS v1, NULL AS v2, NULL AS v3,
data.value AS v4, NULL AS v5
FROM acquisitions INNER JOIN data
ON acquisitions.id = data.id_acq
WHERE acquisitions.id_centr=? and dati.id_mis=?
UNION
SELECT NULL AS v0, NULL AS v1, NULL AS v2, NULL AS v3, NULL AS
v4, data.value AS v5
FROM acquisitions INNER JOIN data
ON acquisitions.id = data.id_acq
WHERE acquisitions.id_centr=? and dati.id_mis=?
) AS T GROUP BY T.datetime""",
myParams
)
Of course the number of UNIONs is not fixed and is built on lenght of
given tuple.
I searched around for it but I see Session.execute just accept bind
params as a mapping.
Thank you for your support
--
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.