1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
Class Mapping
=============
.. module:: sqlalchemy.orm
Defining Mappings
-----------------
Python classes are mapped to the database using the :func:`mapper` function.
.. autofunction:: mapper
Mapper Properties
-----------------
A basic mapping of a class will simply make the columns of the
database table or selectable available as attributes on the class.
**Mapper properties** allow you to customize and add additional
properties to your classes, for example making the results one-to-many
join available as a Python list of :func:`related <relationship>` objects.
Mapper properties are most commonly included in the :func:`mapper`
call::
mapper(Parent, properties={
'children': relationship(Children)
}
.. autofunction:: backref
.. autofunction:: column_property
.. autofunction:: comparable_property
.. autofunction:: composite
.. autofunction:: deferred
.. autofunction:: dynamic_loader
.. autofunction:: relation
.. autofunction:: relationship
.. autofunction:: synonym
Decorators
----------
.. autofunction:: reconstructor
.. autofunction:: validates
Utilities
---------
.. autofunction:: object_mapper
.. autofunction:: class_mapper
.. autofunction:: compile_mappers
.. autofunction:: clear_mappers
Attribute Utilities
-------------------
.. autofunction:: sqlalchemy.orm.attributes.del_attribute
.. autofunction:: sqlalchemy.orm.attributes.get_attribute
.. autofunction:: sqlalchemy.orm.attributes.get_history
.. autofunction:: sqlalchemy.orm.attributes.init_collection
.. function:: sqlalchemy.orm.attributes.instance_state
Return the :class:`InstanceState` for a given object.
.. autofunction:: sqlalchemy.orm.attributes.is_instrumented
.. function:: sqlalchemy.orm.attributes.manager_of_class
Return the :class:`ClassManager` for a given class.
.. autofunction:: sqlalchemy.orm.attributes.set_attribute
.. autofunction:: sqlalchemy.orm.attributes.set_committed_value
Internals
---------
.. autoclass:: sqlalchemy.orm.mapper.Mapper
:members:
.. autoclass:: sqlalchemy.orm.interfaces.MapperProperty
:members:
|