From 147fd7e48b8e9323aff03c05d4203df9966e7051 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 21 Dec 2025 00:47:10 +0000 Subject: [PATCH] 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. --- docs/python-api.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/python-api.rst b/docs/python-api.rst index 267591a..acc2515 100644 --- a/docs/python-api.rst +++ b/docs/python-api.rst @@ -282,11 +282,13 @@ Using this factory function allows you to set :ref:`python_api_table_configurati 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. -You can also access tables or views using dictionary-style syntax, like this: +You can also access tables using dictionary-style syntax, like this: .. code-block:: python - table_or_view = db["my_table_or_view_name"] + table = db["my_table_name"] + +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. 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.