@@ -119,7 +119,7 @@ def cleanup(self):
119119 except : # noqa
120120 pass
121121
122- def query (self , sql , fmt = "CSV" , udf_path = "" ):
122+ def query (self , sql , fmt = "CSV" , udf_path = "" , params = None ):
123123 """Execute a SQL query and return the results.
124124
125125 This method executes a SQL query against the session's database and returns
@@ -138,9 +138,14 @@ def query(self, sql, fmt="CSV", udf_path=""):
138138 - "JSONCompact" - Compact JSON format
139139 - "Arrow" - Apache Arrow format
140140 - "Parquet" - Parquet format
141+ - "DataFrame" - Pandas DataFrame
142+ - "ArrowTable" - PyArrow Table
141143
142144 udf_path (str, optional): Path to user-defined functions. Defaults to "".
143145 If not specified, uses the UDF path from session initialization.
146+ params (dict, optional): Named parameters for ``{name:Type}`` placeholders.
147+ Values must be compatible with the declared ClickHouse type; otherwise
148+ query execution raises a RuntimeError.
144149
145150 Returns:
146151 Query results in the specified format. The exact return type depends on
@@ -197,12 +202,12 @@ def query(self, sql, fmt="CSV", udf_path=""):
197202Eg: conn = connect(f"db_path?verbose&log-level=test")"""
198203 )
199204 fmt = "CSV"
200- return self ._conn .query (sql , fmt )
205+ return self ._conn .query (sql , fmt , params = params )
201206
202207 # alias sql = query
203208 sql = query
204209
205- def send_query (self , sql , fmt = "CSV" ) -> StreamingResult :
210+ def send_query (self , sql , fmt = "CSV" , params = None ) -> StreamingResult :
206211 """Execute a SQL query and return a streaming result iterator.
207212
208213 This method executes a SQL query against the session's database and returns
@@ -221,6 +226,11 @@ def send_query(self, sql, fmt="CSV") -> StreamingResult:
221226 - "JSONCompact" - Compact JSON format
222227 - "Arrow" - Apache Arrow format
223228 - "Parquet" - Parquet format
229+ - "DataFrame" - Pandas DataFrame
230+ - "ArrowTable" - PyArrow Table
231+ params (dict, optional): Named parameters for ``{name:Type}`` placeholders.
232+ Type mismatches or missing required parameters propagate as RuntimeError
233+ when fetching from the stream.
224234
225235 Returns:
226236 StreamingResult: A streaming result iterator that yields query results
@@ -270,4 +280,4 @@ def send_query(self, sql, fmt="CSV") -> StreamingResult:
270280Eg: conn = connect(f"db_path?verbose&log-level=test")"""
271281 )
272282 fmt = "CSV"
273- return self ._conn .send_query (sql , fmt )
283+ return self ._conn .send_query (sql , fmt , params = params )
0 commit comments