On Sep 8, 2008, at 3:27 PM, Diez B. Roggisch wrote:
>
> But it fails with
>
> raise exc.DBAPIError.instance(statement, parameters, e,
> connection_invalidated=is_disconnect)
> OperationalError: (OperationalError) unrecognized token: ":" ...
text() treats :name as a bind parameter, so you'd have to escape the
":" using a backslash "\:\:float". you might have a cleaner
expression if you use a string just for the column expression itself
(also the bind param escaping wouldn't occur):
select
([literal_column
("count(*)::float")]).where(questions.c.id==at.c.question_id)
> Additonally, I'd of course prefer to formulate the subqueries using SA
> as well - but that fails as I can't divide selects.
a select marked as "as_scalar()" should be usable in a division
equation:
>>> from sqlalchemy import *
>>> s = select([1]).as_scalar()
>>> s2 = select([2]).as_scalar()
>>> print s / s2
(SELECT 1) / (SELECT 2)
>>>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---