Well, as is common when I post, I figured out the problem 3 minutes
later. I ditched the join and used:
l = sa.Table( 'connection_log', md, autoload=True )
j = l.alias( 'subselect' )
max = sa.select( [ sa.func.max( j.c.log_id ).label( "max_id" ) ],
j.c.connection_id == sa.func.connection_id(),
group_by = [ j.c.connection_id ] )
l.update( l.c.log_id == max ).execute( comment = 'test' )
However, this brings up two other questions for me:
1) How do I access a table in a schema I'm not connected to? I thought
I remembered seeing something about it either in the docs or on the
list, but I can't seem to find it now?
2) Why doesn't this work?
my_engine.text( "call sys.update_comment( 'test' )" ).execute()
or more simply, how can I call a stored procedure in mysql? I saw the
discussion around the middle of October on stored procs in MySQL and
Firebird, but it seemed to mainly realate to handling procs that return
a cursor and treating them like a table.
Thanks,
e.
Eric Brunson wrote:
> How would I build the following update using SA?
>
> update sys.connection_log
>
> join ( select max( log_id ) id
>
> from sys.connection_log where connection_id = connection_id()
>
> group by connection_id ) as max_id
>
> on max_id.id = sys.connection_log.log_id
>
> set comment = 'blah blah blah';
>
> I've tried stuff along these lines:
>
> l = sa.Table( 'sys.connection_log', md, autoload=True )
>
> j = l.alias( 'log2' )
>
> sel = sa.select( [ sa.func.max( j.c.log_id ).label( "max_id" ) ],
>
> j.c.connection_id == sa.func.connection_id() )
>
> join = sa.join( l, j, l.c.log_id == sel.c.max_id )
>
> update = l.update( from_obj = join )
>
>
> But Table.update() won't take a from_obj parameter and a join object
> doesn't have an update method.
>
> Hints definitely appreciated.
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---