Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1079 Add batch to raw queries #1080

Merged
merged 2 commits into from
Sep 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
link to batch clause from Raw docs page
dantownsend committed Sep 16, 2024
commit c9a7071981953ac0d3f32d85da59e43decf7f0fb
15 changes: 13 additions & 2 deletions docs/src/piccolo/query_types/raw.rst
Original file line number Diff line number Diff line change
@@ -7,15 +7,26 @@ Should you need to, you can execute raw SQL.

.. code-block:: python

>>> await Band.raw('select name from band')
>>> await Band.raw('SELECT name FROM band')
[{'name': 'Pythonistas'}]

It's recommended that you parameterise any values. Use curly braces ``{}`` as
placeholders:

.. code-block:: python

>>> await Band.raw('select * from band where name = {}', 'Pythonistas')
>>> await Band.raw('SELECT * FROM band WHERE name = {}', 'Pythonistas')
[{'name': 'Pythonistas', 'manager': 1, 'popularity': 1000, 'id': 1}]

.. warning:: Be careful to avoid SQL injection attacks. Don't add any user submitted data into your SQL strings, unless it's parameterised.


-------------------------------------------------------------------------------

Query clauses
-------------

batch
~~~~~

See :ref:`batch`.