What is a "toolbox" in the context of SQLAlchemy?

In the SQLAlchemy tutorial , he mentions “tools”, but does not seem to correctly define what measurement equipment is:

These class attributes exist as Python descriptors and define the toolkit for the mapped class. The functionality of this toolkit includes the ability to trigger change events, track changes, and automatically download new data from the database if necessary.

What are tools in this context?

+4
source share
1 answer

- the process of attaching attributes to the class, which are implemented as Python descriptors (this link is mentioned in this sentence), so that any attribute get, set, or delete the operation, that is:

# __get__ print myobject.someattribute # __set__ myobject.someattribute = "foo" # __del__ del myoject.someattribute 

... will invoke Python code for each event, and not use the default Python behavior for direct access / control myobject.__dict__ . SQLAlchemy uses these hooks to provide behaviors such as lazy loading , and also to write when the attribute value changes in order to implement a unit of work where only those elements that have been changed are inserted into UPDATE statements that should be sent to the database upon reset .

+6
source

Source: https://habr.com/ru/post/1401280/


All Articles