Skip to content

SQLAlchemy

[!warning] Historical
Some content in this note may be outdated. Migration guide for SQLAlchemy v1→v2 is now historical; the transition is complete. Kept for historical reference.

Reverse engineering

Use sqlacodegen.

Tips

https://polar.sh/frankie567/posts/sqlalchemy-stop-calling-session-commit
Key takeaways:
- Use session.commit() only once (at the end of your request - this can even be abstracted away in a post-request callback in your web framework)
- Use session.flush() along the way. This might even not be necessary if autoflush is set to True

API v1 → v2

https://matt.sh/sqlalchemy-the-async-ening

See also

Page last modified: 2026-04-06 20:35:09