sqlalchemy events integration to remove deprecated extensions

Revised: integrating sqlalchemy events in place of deprecated extensions