-
I am using OracleDB with Airflow. I have a list of SQL commands that I have parsed from an SQL file and I am trying to run them with OracleDB. There are no parameters for any of the queries. The queries are all run in order, and they all share the same cursor and connection. I am having issue with a stored procedure we use to drop a table if it exists. Essentially we use this method for dropping a table: CREATE OR REPLACE PROCEDURE DROP_TABLE_IF_EXISTS(in_table_name varchar2)
IS
-- from https://stackoverflow.com/a/1799215/6107339
c int;
begin
select count(*) into c from user_tables where table_name = upper('table_name');
if c = 1 then
execute immediate 'drop table table_name';
end if;
end; Normally in our SQL code we would call it by The issue I am having is that straight after we run recreate the table with new data, however, the database complains that the table still exist even though we should have just dropped it. I got the commands to work properly by adding a sql command to compute the first 150 digits of the fibonacci series between each command. By slowing down the execution everything works as expected. Because of this, I feel that the command is not waiting for the procedure to finish. Does anyone know how I would go about telling OracleDB to wait for the previous command to finish before continuing? Things I have tried:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Have you asked in an Airflow forum? How do you know that the connection is shared? Are you using Thin or Thick mode? Which version of python-oracledb are you using? |
Beta Was this translation helpful? Give feedback.
-
Sorry, it turns out the issue was operator error, and had nothing to do with run speed. I was accidentally sending through some empty SQL queries. I haven't looked into it more yet but I think that sending an empty SQL query string causes the last query to repeat. Edit: After looking into it more, it appears that OracleDB won't update Edit 2: I am an idiot. Just above where the code I was looking at was this statement in the documentation:
|
Beta Was this translation helpful? Give feedback.
Sorry, it turns out the issue was operator error, and had nothing to do with run speed.
I was accidentally sending through some empty SQL queries. I haven't looked into it more yet but I think that sending an empty SQL query string causes the last query to repeat.
Edit: After looking into it more, it appears that OracleDB won't update
self._statement
if the statement passed in is an empty string.Edit 2: I am an idiot. Just above where the code I was looking at was this statement in the documentation: