Skip to content

Commit 147fd7e

Browse files
committed
Update docs: db[] only returns tables, not views
Updated python-api.rst to clarify that dictionary-style syntax db["name"] only returns Table objects. Use db.view("name") for views.
1 parent c791a31 commit 147fd7e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

docs/python-api.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,13 @@ Using this factory function allows you to set :ref:`python_api_table_configurati
282282

283283
The ``db.table()`` method will always return a :ref:`reference_db_table` instance, or raise a ``sqlite_utils.db.NoTable`` exception if the table name is actually a SQL view.
284284

285-
You can also access tables or views using dictionary-style syntax, like this:
285+
You can also access tables using dictionary-style syntax, like this:
286286

287287
.. code-block:: python
288288
289-
table_or_view = db["my_table_or_view_name"]
289+
table = db["my_table_name"]
290+
291+
This is equivalent to calling ``db.table("my_table_name")``. It will raise a ``sqlite_utils.db.NoTable`` exception if the name refers to a view rather than a table.
290292

291293
If a table accessed using either of these methods does not yet exist, it will be created the first time you attempt to insert or upsert data into it.
292294

0 commit comments

Comments
 (0)