Skip to content

Commit 6bff8bd

Browse files
Return modified rows
1 parent b461884 commit 6bff8bd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/acquisition/covidcast/database.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,17 +212,18 @@ def insert_or_update_batch(self, cc_rows, batch_size=2**20, commit_partial=False
212212
) for row in cc_rows[start:end]]
213213

214214

215-
result = self._cursor.executemany(insert_into_tmp_sql, args)
215+
self._cursor.executemany(insert_into_tmp_sql, args)
216216
self._cursor.execute(insert_or_update_sql)
217+
modified_row_count = self._cursor.rowcount
217218
self._cursor.execute(zero_is_latest_issue_sql)
218219
self._cursor.execute(set_is_latest_issue_sql)
219220
self._cursor.execute(truncate_tmp_table_sql)
220221

221-
if result is None:
222-
# the SQL connector does not support returning number of rows affected
222+
if modified_row_count is None or modified_row_count == -1:
223+
# the SQL connector does not support returning number of rows affected (see PEP 249)
223224
total = None
224225
else:
225-
total += result
226+
total += modified_row_count
226227
if commit_partial:
227228
self._connection.commit()
228229
except Exception as e:

0 commit comments

Comments
 (0)