Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8536521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:41:14+00:00 2026-06-11T10:41:14+00:00

I am using Flask and a SQLAlchemy extension. Also I am using the declarative

  • 0

I am using Flask and a SQLAlchemy extension. Also I am using the declarative way to write my models as described in the extension’s documentation.

For one of my models, I have some code I need to run after a new row has been inserted, updated or deleted. I was wondering how to do it? Ideally I would just add functions to the model.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:41:15+00:00Added an answer on June 11, 2026 at 10:41 am

    Look at SQLAlchemy’s Mapper Events. You can bind a callback function to the after_insert, after_update, and after_delete events.

    Example:

    from sqlalchemy import event
    
    def after_insert_listener(mapper, connection, target):
        # 'target' is the inserted object
        print(target.id_user)
    
    event.listen(User, 'after_insert', after_insert_listener)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using flask-sqlalchemy to build a webapp and I have the following model(s): class
I have this to SQLAlchemy(using the Flask SqlAlchemy) objects defined: class User(db.Model): id =
I'm using Flask framework with sqlalchemy and I can't query some related table of
I have a web application written using Flask, SQLAlchemy, and MySQL. When I get
I'm using sqlalchemy-flask for my projects as well as json module. I have two
Using Flask, I'm curious to know if SQLAlchemy is still the best way to
I'm using flask as a python framework with sqlalchemy. The models use the query_property
I have a Flask web application using SQLAlchemy with MySQL, and I have set
I have been using Flask for some time now and I am really enjoying
Im using the python framework flask with sqlalchemy. My many-to-many looks like this: collections_questions

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.