Skip to content

Commit

Permalink
Merge pull request #347 from jasonho-lynx/patch-1
Browse files Browse the repository at this point in the history
Add docstring for `substitute_params`
  • Loading branch information
xzkostyan committed Nov 26, 2022
2 parents 087d6c9 + aaa1f3c commit c38d588
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions clickhouse_driver/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,21 @@ def cancel(self, with_column_types=False):
return self.receive_result(with_column_types=with_column_types)

def substitute_params(self, query, params, context):
"""
Substitutes parameters into a provided query.
For example::
client = Client(...)
substituted_query = client.substitute_params(
query='SELECT 1234, %(foo)s',
params={'foo': 'bar'},
context=client.connection.context
)
# prints: SELECT 1234, 'bar'
print(substituted_query)
"""
if not isinstance(params, dict):
raise ValueError('Parameters are expected in dict form')

Expand Down

0 comments on commit c38d588

Please sign in to comment.