MCPcopy
hub / github.com/pandas-dev/pandas / _execute_insert_multi

Method _execute_insert_multi

pandas/io/sql.py:1017–1032  ·  view source on GitHub ↗

Alternative to _execute_insert for DBs support multi-value INSERT. Note: multi-value insert is usually faster for analytics DBs and tables containing a few columns but performance degrades quickly with increase of columns.

(self, conn, keys: list[str], data_iter)

Source from the content-addressed store, hash-verified

1015 return result.rowcount
1016
1017 def _execute_insert_multi(self, conn, keys: list[str], data_iter) -> int:
1018 """
1019 Alternative to _execute_insert for DBs support multi-value INSERT.
1020
1021 Note: multi-value insert is usually faster for analytics DBs
1022 and tables containing a few columns
1023 but performance degrades quickly with increase of columns.
1024
1025 """
1026
1027 from sqlalchemy import insert
1028
1029 data = [dict(zip(keys, row, strict=True)) for row in data_iter]
1030 stmt = insert(self.table).values(data)
1031 result = self.pd_sql.execute(stmt)
1032 return result.rowcount
1033
1034 def insert_data(self) -> tuple[list[str], list[np.ndarray]]:
1035 if self.index is not None:

Callers

nothing calls this directly

Calls 2

valuesMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected