MCPcopy
hub / github.com/pallets-eco/flask-sqlalchemy / _make_metadata

Method _make_metadata

src/flask_sqlalchemy/extension.py:450–475  ·  view source on GitHub ↗

Get or create a :class:`sqlalchemy.schema.MetaData` for the given bind key. This method is used for internal setup. Its signature may change at any time. :meta private: :param bind_key: The name of the metadata being created. .. versionadded:: 3.0

(self, bind_key: str | None)

Source from the content-addressed store, hash-verified

448 self.session.remove()
449
450 def _make_metadata(self, bind_key: str | None) -> sa.MetaData:
451 """Get or create a :class:`sqlalchemy.schema.MetaData` for the given bind key.
452
453 This method is used for internal setup. Its signature may change at any time.
454
455 :meta private:
456
457 :param bind_key: The name of the metadata being created.
458
459 .. versionadded:: 3.0
460 """
461 if bind_key in self.metadatas:
462 return self.metadatas[bind_key]
463
464 if bind_key is not None:
465 # Copy the naming convention from the default metadata.
466 naming_convention = self._make_metadata(None).naming_convention
467 else:
468 naming_convention = None
469
470 # Set the bind key in info to be used by session.get_bind.
471 metadata = sa.MetaData(
472 naming_convention=naming_convention, info={"bind_key": bind_key}
473 )
474 self.metadatas[bind_key] = metadata
475 return metadata
476
477 def _make_table_class(self) -> type[_Table]:
478 """Create a SQLAlchemy :class:`sqlalchemy.schema.Table` class that chooses a

Callers 5

init_appMethod · 0.95
__new__Method · 0.80
__init__Method · 0.80
__init_subclass__Method · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected