@@ -13,7 +13,7 @@ if typing.TYPE_CHECKING:
1313 import pandas
1414 import pyarrow .lib
1515 from collections .abc import Callable , Iterable , Sequence , Mapping
16- from duckdb import sqltypes , func
16+ from duckdb import sqltypes , func , template
1717 from builtins import list as lst # needed to avoid mypy error on DuckDBPyRelation.list method shadowing
1818
1919 # the field_ids argument to to_parquet and write_parquet has a recursive structure
@@ -241,8 +241,12 @@ class DuckDBPyConnection:
241241 def dtype (self , type_str : str ) -> sqltypes .DuckDBPyType : ...
242242 def duplicate (self ) -> DuckDBPyConnection : ...
243243 def enum_type (self , name : str , type : sqltypes .DuckDBPyType , values : lst [typing .Any ]) -> sqltypes .DuckDBPyType : ...
244- def execute (self , query : Statement | str , parameters : object = None ) -> DuckDBPyConnection : ...
245- def executemany (self , query : Statement | str , parameters : object = None ) -> DuckDBPyConnection : ...
244+ def execute (
245+ self , query : Statement | str | template .SqlTemplate | template .CompiledSql , parameters : object = None
246+ ) -> DuckDBPyConnection : ...
247+ def executemany (
248+ self , query : Statement | str | template .SqlTemplate | template .CompiledSql , parameters : object = None
249+ ) -> DuckDBPyConnection : ...
246250 def extract_statements (self , query : str ) -> lst [Statement ]: ...
247251 def fetch_arrow_table (self , rows_per_batch : typing .SupportsInt = 1000000 ) -> pyarrow .lib .Table :
248252 """Deprecated: use to_arrow_table() instead."""
@@ -331,7 +335,9 @@ class DuckDBPyConnection:
331335 union_by_name : bool = False ,
332336 compression : str | None = None ,
333337 ) -> DuckDBPyRelation : ...
334- def from_query (self , query : str , * , alias : str = "" , params : object = None ) -> DuckDBPyRelation : ...
338+ def from_query (
339+ self , query : str | template .SqlTemplate | template .CompiledSql , * , alias : str = "" , params : object = None
340+ ) -> DuckDBPyRelation : ...
335341 def get_table_names (self , query : str , * , qualified : bool = False ) -> set [str ]: ...
336342 def install_extension (
337343 self ,
@@ -360,7 +366,9 @@ class DuckDBPyConnection:
360366 def pl (
361367 self , rows_per_batch : typing .SupportsInt = 1000000 , * , lazy : bool = False
362368 ) -> polars .DataFrame | polars .LazyFrame : ...
363- def query (self , query : str , * , alias : str = "" , params : object = None ) -> DuckDBPyRelation : ...
369+ def query (
370+ self , query : str | template .SqlTemplate | template .CompiledSql , * , alias : str = "" , params : object = None
371+ ) -> DuckDBPyRelation : ...
364372 def query_progress (self ) -> float : ...
365373 def read_csv (
366374 self ,
@@ -462,7 +470,13 @@ class DuckDBPyConnection:
462470 def row_type (
463471 self , fields : dict [str , sqltypes .DuckDBPyType ] | lst [sqltypes .DuckDBPyType ]
464472 ) -> sqltypes .DuckDBPyType : ...
465- def sql (self , query : Statement | str , * , alias : str = "" , params : object = None ) -> DuckDBPyRelation : ...
473+ def sql (
474+ self ,
475+ query : Statement | str | template .SqlTemplate | template .CompiledSql ,
476+ * ,
477+ alias : str = "" ,
478+ params : object = None ,
479+ ) -> DuckDBPyRelation : ...
466480 def sqltype (self , type_str : str ) -> sqltypes .DuckDBPyType : ...
467481 def string_type (self , collation : str = "" ) -> sqltypes .DuckDBPyType : ...
468482 def struct_type (
@@ -1160,7 +1174,7 @@ def enum_type(
11601174 connection : DuckDBPyConnection | None = None ,
11611175) -> sqltypes .DuckDBPyType : ...
11621176def execute (
1163- query : Statement | str ,
1177+ query : Statement | str | template . SqlTemplate | template . CompiledSql ,
11641178 parameters : object = None ,
11651179 * ,
11661180 connection : DuckDBPyConnection | None = None ,
@@ -1282,7 +1296,7 @@ def from_parquet(
12821296 connection : DuckDBPyConnection | None = None ,
12831297) -> DuckDBPyRelation : ...
12841298def from_query (
1285- query : Statement | str ,
1299+ query : Statement | str | template . SqlTemplate | template . CompiledSql ,
12861300 * ,
12871301 alias : str = "" ,
12881302 params : object = None ,
@@ -1350,7 +1364,7 @@ def project(
13501364 df : pandas .DataFrame , * args : _ExpressionLike , groups : str = "" , connection : DuckDBPyConnection | None = None
13511365) -> DuckDBPyRelation : ...
13521366def query (
1353- query : Statement | str ,
1367+ query : Statement | str | template . SqlTemplate | template . CompiledSql ,
13541368 * ,
13551369 alias : str = "" ,
13561370 params : object = None ,
@@ -1474,7 +1488,7 @@ def row_type(
14741488def rowcount (* , connection : DuckDBPyConnection | None = None ) -> int : ...
14751489def set_default_connection (connection : DuckDBPyConnection ) -> None : ...
14761490def sql (
1477- query : Statement | str ,
1491+ query : Statement | str | template . SqlTemplate | template . CompiledSql ,
14781492 * ,
14791493 alias : str = "" ,
14801494 params : object = None ,
0 commit comments