On Jun 3, 2010, at 5:06 AM, Jan-Eric wrote:
> Hi!
>
> I have a problem with constructing a custom SQL statement.
> I would like to create the following SQL
>
> DATA_SUB( <somefixed-date>, INTERVAL <column-expression> MONTHS)
>
> I tried the following approach:
>
> -
> sqlalchemy.func.DATE_SUB(startDate,sqlalchemy.literal_column("INTERVAL
> %s MONTHS" % (exprColumn)))
> this results in the following SQL:
> DATE_SUB(%s, INTERVAL CASE WHEN (interval = %%s) THEN %%s WHEN
> (interval = %%s) THEN %%s WHEN (interval = %%s) THEN %%s END MONTHS)
>
> this doesn't work because % of the expression is escaped. How can I
> prevent this ?
> Should I use a different approach ?
yes, you should use the compiler extension.
http://www.sqlalchemy.org/docs/reference/ext/compiler.html
>
> Thank you in advance!
>
> Jan-Eric
>
> --
> 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.
>
--
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.