From 5b0e4e49d4ab5e976fbfdde70c525a13220f3259 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Fri, 22 Apr 2011 12:14:54 +0000 Subject: Fixed #14091 - be more correct about logging queries in connection.queries. Thanks to Aymeric Augustin for figuring out how to make this work across multiple databases. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16081 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/faq/models.txt | 5 ++--- docs/ref/databases.txt | 12 +++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'docs') diff --git a/docs/faq/models.txt b/docs/faq/models.txt index f00d453d88..5911d9f487 100644 --- a/docs/faq/models.txt +++ b/docs/faq/models.txt @@ -22,9 +22,8 @@ of dictionaries in order of query execution. Each dictionary has the following:: ``connection.queries`` includes all SQL statements -- INSERTs, UPDATES, SELECTs, etc. Each time your app hits the database, the query will be recorded. -Note that the raw SQL logged in ``connection.queries`` may not include -parameter quoting. Parameter quoting is performed by the database-specific -backend, and not all backends provide a way to retrieve the SQL after quoting. +Note that the SQL recorded here may be :ref:`incorrectly quoted under SQLite +`. .. versionadded:: 1.2 diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt index fb97c9f045..82c780cb0f 100644 --- a/docs/ref/databases.txt +++ b/docs/ref/databases.txt @@ -465,7 +465,7 @@ itself to versions newer than the ones included with your particular Python binary distribution, if needed. "Database is locked" errors ------------------------------------------------ +--------------------------- SQLite is meant to be a lightweight database, and thus can't support a high level of concurrency. ``OperationalError: database is locked`` errors indicate @@ -506,6 +506,16 @@ If you're getting this error, you can solve it by: SQLite does not support the ``SELECT ... FOR UPDATE`` syntax. Calling it will have no effect. +.. _sqlite-connection-queries: + +Parameters not quoted in ``connection.queries`` +----------------------------------------------- + +``sqlite3`` does not provide a way to retrieve the SQL after quoting and +substituting the parameters. Instead, the SQL in ``connection.queries`` is +rebuilt with a simple string interpolation. It may be incorrect. Make sure +you add quotes where necessary before copying a query into a SQLite shell. + .. _oracle-notes: Oracle notes -- cgit v1.3