MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / prepare

Method prepare

lib/sqlalchemy/ext/automap.py:1116–1381  ·  view source on GitHub ↗

Extract mapped classes and relationships from the :class:`_schema.MetaData` and perform mappings. For full documentation and examples see :ref:`automap_basic_use`. :param autoload_with: an :class:`_engine.Engine` or :class:`_engine.Connection` with which

(
        cls: Type[AutomapBase],
        autoload_with: Optional[Engine] = None,
        engine: Optional[Any] = None,
        reflect: bool = False,
        schema: Optional[str] = None,
        classname_for_table: Optional[PythonNameForTableType] = None,
        modulename_for_table: Optional[PythonNameForTableType] = None,
        collection_class: Optional[Any] = None,
        name_for_scalar_relationship: Optional[
            NameForScalarRelationshipType
        ] = None,
        name_for_collection_relationship: Optional[
            NameForCollectionRelationshipType
        ] = None,
        generate_relationship: Optional[GenerateRelationshipType] = None,
        reflection_options: Union[
            Dict[_KT, _VT], immutabledict[_KT, _VT]
        ] = util.EMPTY_DICT,
    )

Source from the content-addressed store, hash-verified

1114 ),
1115 )
1116 def prepare(
1117 cls: Type[AutomapBase],
1118 autoload_with: Optional[Engine] = None,
1119 engine: Optional[Any] = None,
1120 reflect: bool = False,
1121 schema: Optional[str] = None,
1122 classname_for_table: Optional[PythonNameForTableType] = None,
1123 modulename_for_table: Optional[PythonNameForTableType] = None,
1124 collection_class: Optional[Any] = None,
1125 name_for_scalar_relationship: Optional[
1126 NameForScalarRelationshipType
1127 ] = None,
1128 name_for_collection_relationship: Optional[
1129 NameForCollectionRelationshipType
1130 ] = None,
1131 generate_relationship: Optional[GenerateRelationshipType] = None,
1132 reflection_options: Union[
1133 Dict[_KT, _VT], immutabledict[_KT, _VT]
1134 ] = util.EMPTY_DICT,
1135 ) -> None:
1136 """Extract mapped classes and relationships from the
1137 :class:`_schema.MetaData` and perform mappings.
1138
1139 For full documentation and examples see
1140 :ref:`automap_basic_use`.
1141
1142 :param autoload_with: an :class:`_engine.Engine` or
1143 :class:`_engine.Connection` with which
1144 to perform schema reflection; when specified, the
1145 :meth:`_schema.MetaData.reflect` method will be invoked within
1146 the scope of this method.
1147
1148 :param engine: legacy; use :paramref:`.AutomapBase.autoload_with`.
1149 Used to indicate the :class:`_engine.Engine` or
1150 :class:`_engine.Connection` with which to reflect tables with,
1151 if :paramref:`.AutomapBase.reflect` is True.
1152
1153 :param reflect: legacy; use :paramref:`.AutomapBase.autoload_with`.
1154 Indicates that :meth:`_schema.MetaData.reflect` should be invoked.
1155
1156 :param classname_for_table: callable function which will be used to
1157 produce new class names, given a table name. Defaults to
1158 :func:`.classname_for_table`.
1159
1160 :param modulename_for_table: callable function which will be used to
1161 produce the effective ``__module__`` for an internally generated
1162 class, to allow for multiple classes of the same name in a single
1163 automap base which would be in different "modules".
1164
1165 Defaults to ``None``, which will indicate that ``__module__`` will not
1166 be set explicitly; the Python runtime will use the value
1167 ``sqlalchemy.ext.automap`` for these classes.
1168
1169 When assigning ``__module__`` to generated classes, they can be
1170 accessed based on dot-separated module names using the
1171 :attr:`.AutomapBase.by_module` collection. Classes that have
1172 an explicit ``__module_`` assigned using this hook do **not** get
1173 placed into the :attr:`.AutomapBase.classes` collection, only

Callers

nothing calls this directly

Calls 15

_is_many_to_manyFunction · 0.85
classname_for_tableFunction · 0.85
_relationships_for_fksFunction · 0.85
_m2m_relationshipFunction · 0.85
reflectMethod · 0.80
classes_for_baseMethod · 0.80
config_for_clsMethod · 0.80
splitMethod · 0.80
castFunction · 0.50
updateMethod · 0.45
differenceMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected