Salohy
05/11/2021, 5:54 PMTypeError: execute() takes no keyword arguments
When running sql query using SqlServerExecute. Here is my task code following the doc explained here https://docs.prefect.io/api/latest/tasks/sql_server.html#sqlserverexecute
from prefect.tasks.sql_server import SqlServerExecute
SQL = SqlServerExecute(db_name="my"Db",
user="user",
host="<tcp:xxxs.database.windows.net>",
port=1433,
driver="ODBC Driver 17 for SQL Server")
QUERY = "CREATE TABLE [dbo].[CandidateDetails] ([CandidateId] VARCHAR(22) COLLATE Latin1_General_100_BIN2 NOT NULL,[FirstName] VARCHAR(222) NULL,[LastName] VARCHAR(222) NULL)"
@task
def create_table():
logger = prefect.context.get('logger')
<http://logger.info|logger.info>("Create table in DW for loading the results")
SQL.run(query=QUERY, password='myPass')
Can you help me on this? many thanks already 🙂Salohy
05/11/2021, 5:55 PMUnexpected error: TypeError('execute() takes no keyword arguments')
Traceback (most recent call last):
File "/opt/conda/lib/python3.8/site-packages/prefect/engine/runner.py", line 48, in inner
new_state = method(self, state, *args, **kwargs)
File "/opt/conda/lib/python3.8/site-packages/prefect/engine/task_runner.py", line 865, in get_task_run_state
value = prefect.utilities.executors.run_task_with_timeout(
File "/opt/conda/lib/python3.8/site-packages/prefect/utilities/executors.py", line 323, in run_task_with_timeout
return task.run(*args, **kwargs) # type: ignore
File "/home/runner/work/dashboards/dashboards/prefect/jobs/KN/candidates.py", line 95, in create_table
File "/opt/conda/lib/python3.8/site-packages/prefect/utilities/tasks.py", line 454, in method
return run_method(self, *args, **kwargs)
File "/opt/conda/lib/python3.8/site-packages/prefect/tasks/sql_server/sql_server.py", line 90, in run
executed = cursor.execute(query=query, vars=data)
TypeError: execute() takes no keyword arguments
Kevin Kho
execute
can’t take any in. I have a PR open to fix this that I haven’t had time to finish. It is here . For now, I suggest you copy this version of the task and rename it and import it into your flow. I think this version should work.Salohy
05/11/2021, 5:59 PM