SQLAlchemy 2.0 Documentation
SQLAlchemy ORM
- ORM Quick Start
- ORM Mapped Class Configuration
- Relationship Configuration
- ORM Querying Guide
- Using the Session
- Events and Internals
- ORM Extensions
- Asynchronous I/O (asyncio)
- Association Proxy
- Automap
- Baked Queries
- Declarative Extensions
- Mypy / Pep-484 Support for ORM Mappings
- Mutation Tracking
- Ordering List
- Horizontal Sharding
- Hybrid Attributes
- Indexable
- Alternate Class Instrumentation¶
- API Reference
INSTRUMENTATION_MANAGER
InstrumentationFactory
InstrumentationManager
InstrumentationManager.dict_getter()
InstrumentationManager.get_instance_dict()
InstrumentationManager.initialize_instance_dict()
InstrumentationManager.install_descriptor()
InstrumentationManager.install_member()
InstrumentationManager.install_state()
InstrumentationManager.instrument_attribute()
InstrumentationManager.instrument_collection_class()
InstrumentationManager.manage()
InstrumentationManager.manager_getter()
InstrumentationManager.post_configure_attribute()
InstrumentationManager.remove_state()
InstrumentationManager.state_getter()
InstrumentationManager.uninstall_descriptor()
InstrumentationManager.uninstall_member()
InstrumentationManager.unregister()
instrumentation_finders
ExtendedInstrumentationRegistry
- API Reference
- ORM Examples
Project Versions
- Previous: Indexable
- Next: ORM Examples
- Up: Home
- On this page:
- Alternate Class Instrumentation
- API Reference
INSTRUMENTATION_MANAGER
InstrumentationFactory
InstrumentationManager
InstrumentationManager.dict_getter()
InstrumentationManager.get_instance_dict()
InstrumentationManager.initialize_instance_dict()
InstrumentationManager.install_descriptor()
InstrumentationManager.install_member()
InstrumentationManager.install_state()
InstrumentationManager.instrument_attribute()
InstrumentationManager.instrument_collection_class()
InstrumentationManager.manage()
InstrumentationManager.manager_getter()
InstrumentationManager.post_configure_attribute()
InstrumentationManager.remove_state()
InstrumentationManager.state_getter()
InstrumentationManager.uninstall_descriptor()
InstrumentationManager.uninstall_member()
InstrumentationManager.unregister()
instrumentation_finders
ExtendedInstrumentationRegistry
- API Reference
Alternate Class Instrumentation¶
Extensible class instrumentation.
The sqlalchemy.ext.instrumentation
package provides for alternate
systems of class instrumentation within the ORM. Class instrumentation
refers to how the ORM places attributes on the class which maintain
data and track changes to that data, as well as event hooks installed
on the class.
Note
The extension package is provided for the benefit of integration with other object management packages, which already perform their own instrumentation. It is not intended for general use.
For examples of how the instrumentation extension is used, see the example Attribute Instrumentation.
API Reference¶
Object Name | Description |
---|---|
Extends |
|
An extensible sequence of callables which return instrumentation implementations |
|
Attribute, elects custom instrumentation when present on a mapped class. |
|
Factory for new ClassManager instances. |
|
User-defined class instrumentation extension. |
- sqlalchemy.ext.instrumentation.INSTRUMENTATION_MANAGER = '__sa_instrumentation_manager__'¶
Attribute, elects custom instrumentation when present on a mapped class.
Allows a class to specify a slightly or wildly different technique for tracking changes made to mapped attributes and collections.
Only one instrumentation implementation is allowed in a given object inheritance hierarchy.
The value of this attribute must be a callable and will be passed a class object. The callable must return one of:
An instance of an
InstrumentationManager
or subclassAn object implementing all or some of InstrumentationManager (TODO)
A dictionary of callables, implementing all or some of the above (TODO)
An instance of a
ClassManager
or subclass
This attribute is consulted by SQLAlchemy instrumentation resolution, once the
sqlalchemy.ext.instrumentation
module has been imported. If custom finders are installed in the global instrumentation_finders list, they may or may not choose to honor this attribute.
- class sqlalchemy.orm.instrumentation.InstrumentationFactory¶
Factory for new ClassManager instances.
Class signature
class
sqlalchemy.orm.instrumentation.InstrumentationFactory
(sqlalchemy.event.registry.EventTarget
)
- class sqlalchemy.ext.instrumentation.InstrumentationManager¶
User-defined class instrumentation extension.
InstrumentationManager
can be subclassed in order to change how class instrumentation proceeds. This class exists for the purposes of integration with other object management frameworks which would like to entirely modify the instrumentation methodology of the ORM, and is not intended for regular usage. For interception of class instrumentation events, seeInstrumentationEvents
.Members
dict_getter(), get_instance_dict(), initialize_instance_dict(), install_descriptor(), install_member(), install_state(), instrument_attribute(), instrument_collection_class(), manage(), manager_getter(), post_configure_attribute(), remove_state(), state_getter(), uninstall_descriptor(), uninstall_member(), unregister()
The API for this class should be considered as semi-stable, and may change slightly with new releases.
-
method
sqlalchemy.ext.instrumentation.InstrumentationManager.
dict_getter(class_)¶
-
method
sqlalchemy.ext.instrumentation.InstrumentationManager.
get_instance_dict(class_, instance)¶
-
method
sqlalchemy.ext.instrumentation.InstrumentationManager.
initialize_instance_dict(class_, instance)¶
-
method
sqlalchemy.ext.instrumentation.InstrumentationManager.
install_descriptor(class_, key, inst)¶
-
method
sqlalchemy.ext.instrumentation.InstrumentationManager.
install_member(class_, key, implementation)¶
-
method
sqlalchemy.ext.instrumentation.InstrumentationManager.
install_state(class_, instance, state)¶
-
method
sqlalchemy.ext.instrumentation.InstrumentationManager.
instrument_attribute(class_, key, inst)¶
-
method
sqlalchemy.ext.instrumentation.InstrumentationManager.
instrument_collection_class(class_, key, collection_class)¶
-
method
sqlalchemy.ext.instrumentation.InstrumentationManager.
manage(class_, manager)¶
-
method
sqlalchemy.ext.instrumentation.InstrumentationManager.
manager_getter(class_)¶
-
method
sqlalchemy.ext.instrumentation.InstrumentationManager.
post_configure_attribute(class_, key, inst)¶
-
method
sqlalchemy.ext.instrumentation.InstrumentationManager.
remove_state(class_, instance)¶
-
method
sqlalchemy.ext.instrumentation.InstrumentationManager.
state_getter(class_)¶
-
method
sqlalchemy.ext.instrumentation.InstrumentationManager.
uninstall_descriptor(class_, key)¶
-
method
sqlalchemy.ext.instrumentation.InstrumentationManager.
uninstall_member(class_, key)¶
-
method
sqlalchemy.ext.instrumentation.InstrumentationManager.
unregister(class_, manager)¶
-
method
- sqlalchemy.ext.instrumentation.instrumentation_finders = [<function find_native_user_instrumentation_hook>]¶
An extensible sequence of callables which return instrumentation implementations
When a class is registered, each callable will be passed a class object. If None is returned, the next finder in the sequence is consulted. Otherwise the return must be an instrumentation factory that follows the same guidelines as sqlalchemy.ext.instrumentation.INSTRUMENTATION_MANAGER.
By default, the only finder is find_native_user_instrumentation_hook, which searches for INSTRUMENTATION_MANAGER. If all finders return None, standard ClassManager instrumentation is used.
- class sqlalchemy.ext.instrumentation.ExtendedInstrumentationRegistry¶
Extends
InstrumentationFactory
with additional bookkeeping, to accommodate multiple types of class managers.
flambé! the dragon and The Alchemist image designs created and generously donated by Rotem Yaari.
Created using Sphinx 7.2.6. Documentation last generated: Thu 12 Dec 2024 05:39:06 PM EST