Babken Vardanyan
Babken Vardanyan

Reputation: 15050

How to get the session ID that my model is attached to?

This is my ORM object:

my_model = models.MyModel.find_by_id(1)

How do I get the SQLAlchemy session number that this object is attached to?

Upvotes: 2

Views: 2803

Answers (1)

Babken Vardanyan
Babken Vardanyan

Reputation: 15050

To get the session ID:

my_model._sa_instance_state.session_id

Upvotes: 5

Related Questions