Skip to content

Commit

Permalink
Merge pull request #262 from FedericoCeratto/patch-1
Browse files Browse the repository at this point in the history
Add hint about SQL injections
  • Loading branch information
xzkostyan committed Oct 25, 2021
2 parents 50da302 + fae5c0b commit 72996bf
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,18 @@ Of course queries can and should be parameterized to avoid SQL injections:
[('2018-10-21', 3)]
Percent symbols in inlined constants should be doubled if you mix constants
with ``%`` symbol and ``%(x)s`` parameters.
with ``%`` symbol and ``%(myvar)s`` parameters.

.. code-block:: python
>>> client.execute(
... "SELECT 'test' like '%%es%%', %(x)s",
... {'x': 1}
... "SELECT 'test' like '%%es%%', %(myvar)s",
... {'myvar': 1}
... )
NOTE: formatting queries using Python's f-strings or concatenation can lead to SQL injections.
Use ``%(myvar)s`` parameters instead.

Customisation ``SELECT`` output with ``FORMAT`` clause is not supported.

.. _execute-with-progress:
Expand Down

0 comments on commit 72996bf

Please sign in to comment.