end += 1
if total_len + record_len >= POSTGRESQL_MAX:
logger.warning("Splitting query due to length.")
yield records[start:end]
start = end
// Reset the total query length
total_len = len(preamble)
After Change
end = 0
total_len = len(preamble)
while end < len(records):
record_len = sum([len(str(v)) for v in records[end].values()])
// Pre-increment to include the end element in the slice
end += 1