Skip to content

Commit

Permalink
use kwargs if args not defined, fix typing
Browse files Browse the repository at this point in the history
  • Loading branch information
oonyoontong committed Jun 5, 2024
1 parent 39779e9 commit 3e6e4ee
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dlt/destinations/impl/databricks/sql_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def execute_sql(
@raise_database_error
def execute_query(self, query: AnyStr, *args: Any, **kwargs: Any) -> Iterator[DBApiCursor]:
curr: DBApiCursor = None
db_args: Optional[Dict[str, Any]]
if args:
keys = [f"arg{i}" for i in range(len(args))]
# Replace position arguments (%s) with named arguments (:arg0, :arg1, ...)
Expand All @@ -102,8 +103,7 @@ def execute_query(self, query: AnyStr, *args: Any, **kwargs: Any) -> Iterator[DB
db_arg = to_py_date(db_arg)
db_args[key] = db_arg
else:
db_args = None
db_args: Optional[Union[Dict[str, Any], Sequence[Any]]]
db_args = kwargs or None
with self._conn.cursor() as curr:
curr.execute(query, db_args)
yield DBApiCursorImpl(curr) # type: ignore[abstract]
Expand Down

0 comments on commit 3e6e4ee

Please sign in to comment.