Reputation: 543
I'm connecting to a SQL Server from Python using jaydebeapi
. When executing multiple ;
-separated SQL-Statements in a single Cursor.execute
-call only errors from the first statement are thrown. Meaning that: when running
curs.execute("""
corrent/successfull insert statement;
insert statement violating a foreign key;
""")
no Error is thrown. How do I make jaydebeapi
or the SQL-Server stop on error?
One option is to use multiple jaydebeapi.Cursor.execute
-calls, i.e.
curs.execute("corrent/successfull insert statement")
curs.execute("insert statement violating a foreign key;")
This is tricky in my situtation, as I need to execute a complete SQL-file which includes newlines and semicolons within quotes. Wrapping inside a transaction (with SET XACT_ABORT ON
) does not work: while the transaction is of course not executed, no Python error is thrown, nor was I able to access any error message on the jaydebeapi.Cursor
.
Upvotes: 1
Views: 409