Skip to content

Commit 148e76b

Browse files
author
Jesse Whitehouse
committed
Update docstring
Signed-off-by: Jesse Whitehouse <jesse.whitehouse@databricks.com>
1 parent 316cae3 commit 148e76b

1 file changed

Lines changed: 25 additions & 6 deletions

File tree

src/databricks/sql/client.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(
7777
Other Parameters:
7878
use_inline_params: `boolean`, optional (default is True)
7979
When True, parameterized calls to cursor.execute() will try to render parameter values inline with the
80-
query text instead of using native bound parameters supported in DBR. This connector will attempt to
80+
query text instead of using native bound parameters supported in DBR 14.1 and above. This connector will attempt to
8181
sanitise parameterized inputs to prevent SQL injection. Before you can switch this to False, you must
8282
update your queries to use the PEP-249 `named` paramstyle instead of the `pyformat` paramstyle used
8383
in INLINE mode.
@@ -608,11 +608,30 @@ def execute(
608608
) -> "Cursor":
609609
"""
610610
Execute a query and wait for execution to complete.
611-
Parameters should be given in extended param format style: %(...)<s|d|f>.
612-
For example:
613-
operation = "SELECT * FROM table WHERE field = %(some_value)s"
614-
parameters = {"some_value": "foo"}
615-
Will result in the query "SELECT * FROM table WHERE field = 'foo' being sent to the server
611+
612+
The parameterisation behaviour of this method depends on which parameter approach is used:
613+
- With INLINE mode (default), parameters are rendered inline with the query text
614+
- With NATIVE mode, parameters are sent to the server separately for binding
615+
616+
This behaviour is controlled by the `use_inline_params` argument passed when building a connection.
617+
618+
The syntax for these approaches is different:
619+
620+
If the connection was instantiated with use_inline_params=False, then parameters
621+
should be given in PEP-249 `named` paramstyle like :param_name
622+
623+
If the connection was instantiated with use_inline_params=True (default), then parameters
624+
should be given in PEP-249 `pyformat` paramstyle like %(param_name)s
625+
626+
```python
627+
inline_operation = "SELECT * FROM table WHERE field = %(some_value)s"
628+
native_operation = "SELECT * FROM table WHERE field = :some_value"
629+
parameters = {"some_value": "foo"}
630+
```
631+
632+
Both will result in the query equivalent to "SELECT * FROM table WHERE field = 'foo'
633+
being sent to the server
634+
616635
:returns self
617636
"""
618637

0 commit comments

Comments
 (0)