Call a stored procedure on MS SQL on Dataiku 11

Dario
Dario Registered Posts: 9 ✭✭✭✭
edited July 16 in Using Dataiku

Hi All:

In the past I was able to run a sotred procedure on PostgreSQL using this executor from Dataiku:
from dataiku import SQLExecutor2

the call to the stored procedure looked like this and it was completely successful:

executor = SQLExecutor2(connection=connection)

df = executor.query_to_df(stored_proc_query)

I am trying to do the same on MS SQL and the

executor.query_to_df(
    'EXEC stored_procedure_name '2023-08-01';
)

does not work the same. Have you tried this before? Have you guys experienced this before?

Thanks,

Dario


Operating system used: linux AWS

Tagged:

Best Answer

  • Dario
    Dario Registered Posts: 9 ✭✭✭✭
    Answer ✓

    Thanks for the suggestion. Reason we are using it within a Python recipe is the call to execute the stored procedure has dynamic parameters. We call the stored procedure from MS SQL using a different argument every time.

    I've managed to fix the issues. The Python recipe is executing the stored procedure using

    'EXEC stored_procedure_name '2023-08-01';

    and we got the required results.

    Thanks very much.

    BTW: On PostgreSQL we use 'Call'. On MS SQL we use 'EXEC'.

Answers

  • JordanB
    JordanB Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 295 Dataiker

    HI @darioromero
    ,

    Can you please try using "CALL" instead of "EXEC" here? We typically recommend running your procedures in SQL notebooks or SQL script recipes, just consider this documentation if you decide to call procedures inside SQL recipes.

    Thanks,

    Jordan

Setup Info
    Tags
      Help me…