Michael Bayer ha scritto:
> Glauco wrote:
>   
>> I don't know if is better to use the psycopg adapter.
>>
>> Can i use the funct.* function only as adapter?
>>
>> example:
>>
>> In [1]: aa = [1,2,3,4,]
>>
>> In [2]: print sa.func.in_( *aa )
>> in(:in, :in_1, :in_2, :in_3)
>>
>> how to obtain  this?
>> in ( 1,2,3,4 )
>>     
>
> perhaps you're looking for  sa.func.in_(*[literal_column(x) for x in aa]) ?
>   
not exactly.

In [13]: print sa.func.in_( *[sa.func.literal_column(x) for x in 
[1,2,3]] ).compile()
in(literal_column(:literal_column), literal_column(:literal_column_1), 
literal_column(:literal_column_2))



What i mean is similar to psycopg adapter:

class SQL_IN(object):
    """Adapt a tuple to an SQL quotable object."""
    
    def __init__(self, seq):
        self._seq = seq
        
    def getquoted(self):
        # this is the important line: note how every object in the
        # list is adapted and then how getquoted() is called on it

        qobjs = [str(psycoadapt(o).getquoted()) for o in self._seq]

        return '(' + ', '.join(qobjs) + ')'
        
    __str__ = getquoted



> I'm not sure what this accomplishes for you overall, however.
>
>
>   
I know this is not a good practise of SA, but this is a small isolated 
case. Here i don't have access to my mappers, so i create manually the 
SQL and after all i use the engine to execute.
so i find useful to use adapter.


Thank you
Glauco

-- 
+------------------------------------------------------------+
 Glauco Uri  
 glauco(at)sferacarta.com 
                               
          Sfera Carta Software®       info(at)sferacarta.com
  Via Bazzanese,69  Casalecchio di Reno(BO) - Tel. 051591054
+------------------------------------------------------------+



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