Search code snippets, questions, articles...

Delete records query in SQLAlchemy

To delete rows or records from a table using SQLAlchemy you can use the .delete() method of SQLAlchemy.
self.session.query(
    UserModel
).filter(
    UserModel.id == 100
).delete(synchronize_session=False)

self.session.commit()
Output
Delete records from users table where id is 100

The code will delete all the rows in the user table where the value of the id column will be 100.

Was this helpful?
0 Comments
Programming Feeds
Learn something new everyday on Devsheet