On Tue, Jul 27, 2010 at 11:35 AM, Jon Nelson <[email protected]> wrote:
> On Tue, Jul 27, 2010 at 11:08 AM, Michael Bayer
> <[email protected]> wrote:
>>
>> On Jul 27, 2010, at 11:49 AM, Jon Nelson wrote:
>>
>>> I have two questions:
>>>
>>> 1. I'm using postgresql, and I sometimes need to do column type
>>> conversions. In postgresql, this is normally done with the ::FOO
>>> operator where FOO is a data *type*.  Somtimes, but not usually, these
>>> data types are also available in function-like factories, but in this
>>> case that doesn't help me. SHould I use the cast(some_column, 'int')
>>> expression here?
>>
>> ::FOO in PG is their internal syntax for what CAST provides, yes.
>>
>>>
>>> 2. Frequently, I have a list of things upon which to operate. This
>>> list of things is not in a table, and I may want to call a function on
>>> this list of things. If I were writing the sql directly, I'd do
>>> something like this:
>>>
>>> select function_foo(BAR.x) FROM (select value1, value2, value3) BAR(x);
>>>
>>> What's the best way to emulate this with sqlalchemy?
>>
>> there's a recipe for VALUES at 
>> http://www.sqlalchemy.org/trac/wiki/UsageRecipes/PGValues , the syntax you 
>> have above looks unfamiliar to me but VALUES will create a lexical "table" 
>> from a set of literals (or you can just modify that recipe to provide the 
>> exact syntax you want).
>

Never mind my previous request - I was using it wrong.
Sigh.

That recipe works perfectly.

Michael - since VALUES is part of the SQL standard (as indicated here:
http://www.postgresql.org/docs/8.4/static/sql-values.html ) perhaps
values could be added to sqlalchemy in a future release?



-- 
Jon

-- 
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.

Reply via email to