[sqlalchemy] Re: how to run a stored procedure?

2010-07-21 Thread Lukasz Szybalski

 how is calling query(colmames)...all() significantly different from simply 
 saying execute(..).fetchall() ?  you get a list of named-tuple like objects 
 in both cases.

You are correct, execute().fetchall() does already returns a list of
rows, where each row has attributes. I was initially using execute()
and couldn't pass in the myresults[5] so I assumed this was returning
a list of results strings and not tuple, but they do.

I will use fetchall, and I am able to use myresults[5].customername

I'll update my docs with these example.
http://lucasmanual.com/mywiki/PythonManual#sqlalchemyandmssql

I wonder if passing arguments like this is mssql specific
(@some_input_parameter) , or it can be reused in other databases, like
mysql or postgre?

myresults=session.execute(assp_ReportDailyTransactions
@start_date=:start,@end_date=:end,
params={'start':20100701,'end':20100719})

Thanks a lot.
Lucas


--
How to setup unix odbc for use with sqlalchemy and mssql
http://lucasmanual.com/mywiki/unixODBC

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] SessionExtensions not firing

2010-07-21 Thread Max
Hi Group,

We are currently working on an issue where we want to use the
SessionExtension ability.  However, we run into a problem when our
session.flush() has no changes to be made.  However at the same time
we
have processing that we want to happen after the flush in the form of
deferred operations.  We tried overriding the after_flush_postexec but
this does not get fired in the case of a non-dirty session.  We also
found that other of the extension methods do not get fired when the
session isn't dirty.  Is there a specific reason for this?  We would
like to avoid having to override the flush method to get the proper
functioning.

Basically, I think the extensions should fire regardless of the state
of
the session. But that is just me, I am not sure if there are reasons
to
not want this for other cases.

Thanks,

Max

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] SessionExtensions not firing

2010-07-21 Thread Michael Bayer

On Jul 21, 2010, at 10:37 AM, Max wrote:

 Hi Group,
 
 We are currently working on an issue where we want to use the
 SessionExtension ability.  However, we run into a problem when our
 session.flush() has no changes to be made.  However at the same time
 we
 have processing that we want to happen after the flush in the form of
 deferred operations.  We tried overriding the after_flush_postexec but
 this does not get fired in the case of a non-dirty session.  We also
 found that other of the extension methods do not get fired when the
 session isn't dirty.  Is there a specific reason for this?  We would
 like to avoid having to override the flush method to get the proper
 functioning.
 
 Basically, I think the extensions should fire regardless of the state
 of
 the session. But that is just me, I am not sure if there are reasons
 to
 not want this for other cases.

The extensions refer to when a flush of pending state actually takes place. 
Nothing happens for an empty flush(), since empty flushes are extremely common 
the library conserves as many method calls as possible for these.   

If you need something to happen every time the actual flush() method is called, 
you would need to subclass Session and override flush() to perform your 
additional tasks.  sessionmaker() accepts a class_ argument for this purpose. 
  Or, call a distinct method of your own (on a Session subclass or not), since 
it seems like you have special semantics that you are attaching to the flush() 
call that aren't normally there.  For example - flush() is called for every 
execution of Query.  What does your extension do that it needs to execute every 
time a Query on an otherwise clean session executes a statement ?   If three 
statements are executed in succession, you extension then needs to do something 
for all three ?


-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] SessionExtensions not firing

2010-07-21 Thread mwalton
Basically, we have some actions that are performed by direct database
access that happen in a deferred state.  When we flush, we want to
process these deferred actions.  So it looks like we will need to
continue overriding the session flush. 

Thanks for your quick reply.

Max

On Wed, 2010-07-21 at 12:12 -0400, Michael Bayer wrote:
 On Jul 21, 2010, at 10:37 AM, Max wrote:
 
  Hi Group,
  
  We are currently working on an issue where we want to use the
  SessionExtension ability.  However, we run into a problem when our
  session.flush() has no changes to be made.  However at the same time
  we
  have processing that we want to happen after the flush in the form of
  deferred operations.  We tried overriding the after_flush_postexec but
  this does not get fired in the case of a non-dirty session.  We also
  found that other of the extension methods do not get fired when the
  session isn't dirty.  Is there a specific reason for this?  We would
  like to avoid having to override the flush method to get the proper
  functioning.
  
  Basically, I think the extensions should fire regardless of the state
  of
  the session. But that is just me, I am not sure if there are reasons
  to
  not want this for other cases.
 
 The extensions refer to when a flush of pending state actually takes place.   
   Nothing happens for an empty flush(), since empty flushes are extremely 
 common the library conserves as many method calls as possible for these.   
 
 If you need something to happen every time the actual flush() method is 
 called, you would need to subclass Session and override flush() to perform 
 your additional tasks.  sessionmaker() accepts a class_ argument for this 
 purpose.   Or, call a distinct method of your own (on a Session subclass or 
 not), since it seems like you have special semantics that you are attaching 
 to the flush() call that aren't normally there.  For example - flush() is 
 called for every execution of Query.  What does your extension do that it 
 needs to execute every time a Query on an otherwise clean session executes a 
 statement ?   If three statements are executed in succession, you extension 
 then needs to do something for all three ?
 
 

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.