0

I'm trying to create procedure on Teradata using turbodbc. There is my sample code:

from turbodbc import connect
con = connect(dsn="Teradata")
cur = con.cursor()
cur.execute("""
create procedure dev.test_procedure (
) sql security invoker 
begin 
    delete dev.test_table;
end;
""")

And got this error:

DatabaseError: ODBC error
state: 42000
native error code: -3706
message: [Teradata][ODBC Teradata Driver][Teradata Database] Syntax error:
Invalid  SQL Statement.

But the same code works with no errors in Teradata SQL Assistant. What's wrong?

anfrolov
  • 1
  • 1
  • Perhaps using DBQL on the Teradata side to capture the actual incorrect SQL statement text would give a clue as to the issue. – Fred Mar 09 '20 at 21:30

1 Answers1

0

Possible solution is use teradatasql. This sample works fine:

import teradatasql
with teradatasql.connect(
    '{"host":"my_host","user":"my_user","password":"my_password"}'
) as con:
    with con.cursor() as cur:
        cur.execute("""
            create procedure dev.test_procedure (
            ) sql security invoker 
            begin 
                delete dev.test_table ; 
            end ; 
            """)

But, it will be good if someone knows solution with turbodbc.

anfrolov
  • 1
  • 1