Documentation for db.quote_fts(), refs #246

This commit is contained in:
Simon Willison 2021-08-18 11:55:50 -07:00
commit 1fa5a12a49

View file

@ -1909,6 +1909,18 @@ To remove the FTS tables and triggers you created, use the ``disable_fts()`` tab
db["dogs"].disable_fts()
.. _python_api_quote_fts:
Quoting characters for use in search
------------------------------------
SQLite supports `advanced search query syntax <https://www.sqlite.org/fts3.html#full_text_index_queries>`__. In some situations you may wish to disable this, since characters such as ``.`` may have special meaning that causes errors when searching for strings provided by your users.
The ``db.quote_fts(query)`` method returns the query with SQLite full-text search quoting applied such that the query should be safe to use in a search::
db.quote_fts("Search term.")
# Returns: '"Search" "term."'
.. _python_api_fts_search:
Searching with table.search()