Skip to content

Commit 8bf978d

Browse files
committed
added docs for Table tags
1 parent 4143a38 commit 8bf978d

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

docs/src/piccolo/projects_and_apps/piccolo_apps.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ auto migrations (see :ref:`Migrations`).
105105
You can register them manually, see the example above, or can use
106106
``table_finder``.
107107

108+
.. _TableFinder:
109+
108110
table_finder
109111
------------
110112

@@ -127,6 +129,8 @@ list of modules.
127129
The module path should be from the root of the project (the same directory as
128130
your ``piccolo_conf.py`` file, rather than a relative path).
129131

132+
You can filter the ``Table`` subclasses returned using tags (see :ref:`TableTags`).
133+
130134
.. currentmodule:: piccolo.conf.apps
131135

132136
.. autofunction:: table_finder
@@ -160,7 +164,7 @@ and docstrings. Here's an example:
160164
"""
161165
print(name)
162166
163-
We then register it with the `AppConfig`.
167+
We then register it with the ``AppConfig``.
164168

165169
.. code-block:: python
166170

docs/src/piccolo/schema/advanced.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,18 @@ Here is an example of a more complex ``Readable``.
4747
4848
As you can see, the template can include multiple columns, and can contain your
4949
own text.
50+
51+
-------------------------------------------------------------------------------
52+
53+
.. _TableTags:
54+
55+
Table Tags
56+
----------
57+
58+
``Table`` subclasses can be given tags. The tags can be used for filtering,
59+
for example with ``table_finder`` (see :ref:`TableFinder`).
60+
61+
.. code-block:: python
62+
63+
class Band(Table, tags=["music"]):
64+
name = Varchar(length=100)

piccolo/table.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@ def __init_subclass__(
103103
"""
104104
Automatically populate the _meta, which includes the tablename, and
105105
columns.
106+
107+
:param tablename:
108+
Specify a custom tablename. By default the classname is converted
109+
to snakecase.
110+
:param db:
111+
Manually specify an engine to use for connecting to the database.
112+
Useful when writing simple scripts. If not set, the engine is
113+
imported from piccolo_conf.py using ``engine_finder``.
114+
:param tags:
115+
Used for filtering, for example by ``table_finder``.
116+
106117
"""
107118
tablename = tablename if tablename else _camel_to_snake(cls.__name__)
108119

0 commit comments

Comments
 (0)