Код: Выделить всё
try:
# Check if ETL is running
check_isrunning_sms_journals = "select nvl(d.is_running,0) as is_running from running_etl_table d where upper(d.table_name) = 'SMS_JOURNALS'"
oracle_cursor.execute(check_isrunning_sms_journals)
for row in oracle_cursor.fetchall():
is_running = row[0]
# run ETL if it's not running
if is_running == 0:
update_query = """update running_etl_table a
set a.is_running = 1
where upper(a.table_name) = 'SMS_JOURNALS' """
oracle_cursor.execute(update_query)
oracleDB.commit()
Код: Выделить всё
except Exception as e:
print("An error occurred:", str(e))
try:
oracle_cursor.execute("""update running_etl_table
set is_running = 0
where upper(table_name) = 'SMS_JOURNALS'
""")
oracleDB.commit()
print("is_running reset to 0 due to error")
except Exception as inner_e:
print("Failed to reset is_running flag:", str(inner_e))
sys.exit(1) # make ODI mark job as failed
else:
oracle_cursor.execute("""update running_etl_table
set is_running = 0
where upper(table_name) = 'SMS_JOURNALS' """)
oracleDB.commit()
print("is_running reset to 0")
Я хочу знать, правильно ли я это обрабатываю и есть ли лучшие и более надежные решения.
Заранее спасибо
Подробнее здесь: https://stackoverflow.com/questions/798 ... -occurs-du
Мобильная версия