Taragolis commented on code in PR #38715:
URL: https://github.com/apache/airflow/pull/38715#discussion_r1550075887
##########
airflow/providers/common/sql/hooks/sql.py:
##########
@@ -545,35 +541,19 @@ def insert_rows(
conn.commit()
with closing(conn.cursor()) as cur:
- if executemany:
- for chunked_rows in chunked(rows, commit_every):
- values = list(
- map(
- lambda row: tuple(map(lambda cell:
self._serialize_cell(cell, conn), row)),
- chunked_rows,
- )
+ for chunked_rows in chunked(rows, commit_every):
+ values = list(
+ map(
+ lambda row: tuple(map(lambda cell:
self._serialize_cell(cell, conn), row)),
+ chunked_rows,
)
- sql = self._generate_insert_sql(table, values[0],
target_fields, replace, **kwargs)
- self.log.debug("Generated sql: %s", sql)
- cur.fast_executemany = True
- cur.executemany(sql, values)
- conn.commit()
- self.log.info("Loaded %s rows into %s so far",
len(chunked_rows), table)
- else:
- for i, row in enumerate(rows, 1):
- lst = []
- for cell in row:
- lst.append(self._serialize_cell(cell, conn))
- values = tuple(lst)
- sql = self._generate_insert_sql(table, values,
target_fields, replace, **kwargs)
- self.log.debug("Generated sql: %s", sql)
- cur.execute(sql, values)
- if commit_every and i % commit_every == 0:
- conn.commit()
- self.log.info("Loaded %s rows into %s so far", i,
table)
-
- if not executemany:
- conn.commit()
+ )
+ sql = self._generate_insert_sql(table, values[0],
target_fields, replace, **kwargs)
+ self.log.debug("Generated sql: %s", sql)
+ cur.fast_executemany = True
Review Comment:
I can't find into the [Database API Specification
v2.0](https://peps.python.org/pep-0249/) any information about
`fast_executemany`. Let me guess it is only related to some specific dialect
and some specific driver and would not work in the other Hooks? Just a reminder
that there is about 24 classes which depend on this onve
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]