You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor the contact creation logic to paginate contact creation using a constant CONTACTS_CREATION_BATCH_SIZE. Loop over the contacts to create and insert them by batch.
Define CONTACTS_CREATION_BATCH_SIZE in a constants file (e.g., constants.py):
CONTACTS_CREATION_BATCH_SIZE=100# Adjust the batch size as needed
Update the contact creation logic to use batching. For example, in contact_service.py:
from .constantsimportCONTACTS_CREATION_BATCH_SIZE# Assuming `contacts` is a list of contacts to be createdforiinrange(0, len(contacts), CONTACTS_CREATION_BATCH_SIZE):
batch=contacts[i:i+CONTACTS_CREATION_BATCH_SIZE]
# Insert the batch of contactsinsert_contacts(batch)
Ensure the insert_contacts function handles the batch insertion logic.
Scope & Context
When too many contacts are created in the same query, we have an error.
Technical inputs
Paginate contact creation to avoid this problem:
The text was updated successfully, but these errors were encountered: