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

Method create_all

src/flask_sqlalchemy/extension.py:883–900  ·  view source on GitHub ↗

Create tables that do not exist in the database by calling ``metadata.create_all()`` for all or some bind keys. This does not update existing tables, use a migration library for that. This requires that a Flask application context is active. :param bind_key: A bind

(self, bind_key: str | None | list[str | None] = "__all__")

Source from the content-addressed store, hash-verified

881 getattr(metadata, op_name)(bind=engine)
882
883 def create_all(self, bind_key: str | None | list[str | None] = "__all__") -> None:
884 """Create tables that do not exist in the database by calling
885 ``metadata.create_all()`` for all or some bind keys. This does not
886 update existing tables, use a migration library for that.
887
888 This requires that a Flask application context is active.
889
890 :param bind_key: A bind key or list of keys to create the tables for. Defaults
891 to all binds.
892
893 .. versionchanged:: 3.0
894 Renamed the ``bind`` parameter to ``bind_key``. Removed the ``app``
895 parameter.
896
897 .. versionchanged:: 0.12
898 Added the ``bind`` and ``app`` parameters.
899 """
900 self._call_for_binds(bind_key, "create_all")
901
902 def drop_all(self, bind_key: str | None | list[str | None] = "__all__") -> None:
903 """Drop tables by calling ``metadata.drop_all()`` for all or some bind keys.

Callers 15

test_track_modificationsFunction · 0.95
test_declaredattrFunction · 0.95
test_abstractmodelFunction · 0.95
test_mixinmodelFunction · 0.95
test_get_or_404_kwargsFunction · 0.95
test_create_drop_allFunction · 0.95
test_create_key_specFunction · 0.95
test_reflectFunction · 0.95

Calls 1

_call_for_bindsMethod · 0.95

Tested by 15

test_track_modificationsFunction · 0.76
test_declaredattrFunction · 0.76
test_abstractmodelFunction · 0.76
test_mixinmodelFunction · 0.76
test_get_or_404_kwargsFunction · 0.76
test_create_drop_allFunction · 0.76
test_create_key_specFunction · 0.76
test_reflectFunction · 0.76