Skip to content

Instantly share code, notes, and snippets.

@guyoun
Created March 14, 2016 05:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guyoun/e2544bc81f346bc498e2 to your computer and use it in GitHub Desktop.
Save guyoun/e2544bc81f346bc498e2 to your computer and use it in GitHub Desktop.
Usage of listens_for() in sqlalchemy
from sqlalchemy import event
@event.listens_for(Model, 'after_update')
@event.listens_for(Model, 'after_delete')
@event.listens_for(Model, 'after_insert')
def receive_after_change(mapper, connection, target):
from flask import current_app
current_app.logger.info('Model>receive_after_change')
from subprocess import call
call("touch tmp/reload", shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment