From 1fa5a12a4952b02341e2a59ba75aabb740518ecb Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Wed, 18 Aug 2021 11:55:50 -0700 Subject: [PATCH] Documentation for db.quote_fts(), refs #246 --- docs/python-api.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/python-api.rst b/docs/python-api.rst index b793920..0a0e1df 100644 --- a/docs/python-api.rst +++ b/docs/python-api.rst @@ -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 `__. 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()