diff options
| author | Michael Merickel <github@m.merickel.org> | 2024-02-07 21:02:40 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-07 21:02:40 -0700 |
| commit | 03e2e439f263aca7d4efa8173c0bbc4aacb8a3c2 (patch) | |
| tree | a052858496fce4e03b16098cc11e9b8a0aba1617 /docs/tutorials/wiki2/basiclayout.rst | |
| parent | 53eb7e7cc6b7bfdedb4df4821af66619bebf909c (diff) | |
| parent | 222386e96a1711b6215f64ea809a9f4a7a8c2202 (diff) | |
| download | pyramid-03e2e439f263aca7d4efa8173c0bbc4aacb8a3c2.tar.gz pyramid-03e2e439f263aca7d4efa8173c0bbc4aacb8a3c2.tar.bz2 pyramid-03e2e439f263aca7d4efa8173c0bbc4aacb8a3c2.zip | |
Merge pull request #3747 from Pylons/wiki2-sqla-2.0
upgrade the wiki2 tutorial with the new cookiecutter updates
Diffstat (limited to 'docs/tutorials/wiki2/basiclayout.rst')
| -rw-r--r-- | docs/tutorials/wiki2/basiclayout.rst | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/docs/tutorials/wiki2/basiclayout.rst b/docs/tutorials/wiki2/basiclayout.rst index ef78e052b..63171fa99 100644 --- a/docs/tutorials/wiki2/basiclayout.rst +++ b/docs/tutorials/wiki2/basiclayout.rst @@ -218,29 +218,14 @@ following: :linenos: :language: py -``meta.py`` contains imports and support code for defining the models. We -create a dictionary ``NAMING_CONVENTION`` as well for consistent naming of -support objects like indices and constraints. +``meta.py`` contains imports and support code for defining the models. -.. literalinclude:: src/basiclayout/tutorial/models/meta.py - :end-before: metadata - :linenos: - :language: py - -Next we create a ``metadata`` object from the class -:class:`sqlalchemy.schema.MetaData`, using ``NAMING_CONVENTION`` as the value -for the ``naming_convention`` argument. +The core goal of ``meta.py`` is to define a declarative base class (``Base``) that links all of our models together into a shared :class:`sqlalchemy.schema.MetaData`. -A ``MetaData`` object represents the table and other schema definitions for a -single database. We also need to create a declarative ``Base`` object to use as -a base class for our models. Our models will inherit from this ``Base``, which -will attach the tables to the ``metadata`` we created, and define our -application's database schema. +We create the :class:`sqlalchemy.schema.MetaData` with a ``naming_convention`` to support properly naming objects when generating migrations with ``alembic``. -.. literalinclude:: src/basiclayout/tutorial/models/meta.py - :lines: 15-16 - :lineno-match: - :language: py +Any object inheriting from the new ``Base`` will be attached to ``metadata`` and +are able to reference eachother in relationships by name. Next open ``tutorial/models/mymodel.py``, which should already contain the following: |
