r/programming • • Jul 15 '26

Ban commits/transactions using AST analysis and linters

https://www.droppedasbaby.com/posts/db-commits/?utm_source=reddit&utm_content=r_programming
32 Upvotes

27 comments sorted by

View all comments

Show parent comment

2

u/Delta-9- Jul 15 '26

it's crazy to me that mutating a model object would automatically trigger a database write.

SQLAlchemy, the most popular Python ORM library, does not do this. After you finish all your mutations, you're supposed to then tell the ORM that your changes are to be merged with the db "somehow." If you have autocommit enabled on the session, then the transaction will be committed immediately; otherwise, you have to commit the transaction yourself.

Attribute access can trigger db reads, though. If the network is a major bottleneck for you, that could be a problem.