Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The 'cx_Oracle' driver does support autocommit #20085

Merged
merged 1 commit into from
Dec 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions airflow/providers/oracle/hooks/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class OracleHook(DbApiHook):
conn_type = 'oracle'
hook_name = 'Oracle'

supports_autocommit = False
supports_autocommit = True

def get_conn(self) -> 'OracleHook':
"""
Expand Down Expand Up @@ -177,10 +177,9 @@ def insert_rows(
else:
target_fields = ''
conn = self.get_conn()
cur = conn.cursor() # type: ignore[attr-defined]
if self.supports_autocommit:
cur.execute('SET autocommit = 0')
conn.commit() # type: ignore[attr-defined]
self.set_autocommit(conn, False)
cur = conn.cursor() # type: ignore[attr-defined]
i = 0
for row in rows:
i += 1
Expand Down Expand Up @@ -238,6 +237,8 @@ def bulk_insert_rows(
if not rows:
raise ValueError("parameter rows could not be None or empty iterable")
conn = self.get_conn()
if self.supports_autocommit:
self.set_autocommit(conn, False)
cursor = conn.cursor() # type: ignore[attr-defined]
values_base = target_fields if target_fields else rows[0]
prepared_stm = 'insert into {tablename} {columns} values ({values})'.format(
Expand Down