class AutomapBase(object):
Base class for an "automap" schema.
The .AutomapBase
class can be compared to the "declarative base"
class that is produced by the .declarative.declarative_base
function. In practice, the .AutomapBase
class is always used
as a mixin along with an actual declarative base.
A new subclassable .AutomapBase
is typically instantiated
using the .automap_base
function.
See Also
Class Method | prepare |
Extract mapped classes and relationships from the _schema.MetaData and perform mappings. |
Class Variable | classes |
An instance of .util.Properties containing classes. |
Class Method | _sa_raise_deferred_config |
Undocumented |
Class Variable | __abstract__ |
Undocumented |
Class Variable | _sa_decl_prepare |
Indicate that the mapping of classes should be deferred. |
_schema.MetaData
and
perform mappings.Parameters | |
autoload_with | Undocumented |
engine | an _engine.Engine or
_engine.Connection with which
to perform schema reflection, if specified.
If the :paramref:`.AutomapBase.prepare.reflect` argument is False,
this object is not used. |
reflect | if True, the _schema.MetaData.reflect
method is called
on the _schema.MetaData associated with this
.AutomapBase .
The _engine.Engine passed via
:paramref:`.AutomapBase.prepare.engine` will be used to perform the
reflection if present; else, the _schema.MetaData
should already be
bound to some engine else the operation will fail. |
schema | When present in conjunction with the
:paramref:`.AutomapBase.prepare.reflect` flag, is passed to
New in version 1.1.
|
classname_for_table | callable function which will be used to
produce new class names, given a table name. Defaults to
.classname_for_table . |
collection_class | the Python collection class that will be used
when a new _orm.relationship
object is created that represents a
collection. Defaults to list. |
name_for_scalar_relationship | callable function which will be
used to produce relationship names for scalar relationships. Defaults
to .name_for_scalar_relationship . |
name_for_collection_relationship | callable function which will
be used to produce relationship names for collection-oriented
relationships. Defaults to .name_for_collection_relationship . |
generate_relationship | callable function which will be used to
actually generate _orm.relationship and .backref
constructs. Defaults to .generate_relationship . |
reflection_options | When present, this dictionary of options
will be passed to
New in version 1.4.
|
An instance of .util.Properties
containing classes.
This object behaves much like the .c collection on a table. Classes are present under the name they were given, e.g.:
Base = automap_base() Base.prepare(engine=some_engine, reflect=True) User, Address = Base.classes.User, Base.classes.Address
bool
=
Indicate that the mapping of classes should be deferred.
The presence of this attribute name indicates to declarative that the call to mapper() should not occur immediately; instead, information about the table and attributes to be mapped are gathered into an internal structure called _DeferredMapperConfig. These objects can be collected later using classes_for_base(), additional mapping decisions can be made, and then the map() method will actually apply the mapping.
The only real reason this deferral of the whole thing is needed is to support primary key columns that aren't reflected yet when the class is declared; everything else can theoretically be added to the mapper later. However, the _DeferredMapperConfig is a nice interface in any case which exists at that not usually exposed point at which declarative has the class and the Table but hasn't called mapper() yet.