On Jan 11, 2014, at 1:11 PM, Ed Willis <[email protected]> wrote:

> Say I've got more than one database (in my specific example, they're sqlite3 
> databases).  All the databases have the same table declarations in their 
> schemas.  I want to listen for insert/update/delete events in one specific 
> database and then propagate data from that database to the others.  What I've 
> seen in SQLAlchemy 0.7 (we're a ways back, yes) is that there doesn't seem to 
> be an easy way for me to either filter out the event notifications to just 
> the one databases of interest OTOH or work out which database the data came 
> from when the event is triggered OTO.  
> 
> Does anyone know of an easy way to limit event notifications to just one 
> database?

event.listen() accepts an Engine instance, not just a class, as a target:

db1 = create_engine(..)
db2 = create_engine(..)
db3 = create_engine(..)

@event.listens_for(db1, “execute”)
def only_db1_events(…):
  …

more info: http://docs.sqlalchemy.org/en/rel_0_9/core/event.html#targets


hope this helps



> 
> Thanks!
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/groups/opt_out.

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to