Fixed `(sqlite3.OperationalError) too many SQL variables issue` while inserting too many episodes at the same time.

pull/2304/head
morpheus65535 1 year ago
parent 164d487f06
commit a10e5dbf37

@ -94,12 +94,14 @@ def sync_episodes(series_id, send_event=True):
# Update existing episodes in DB # Update existing episodes in DB
if len(episodes_to_update): if len(episodes_to_update):
try: for updated_episode in episodes_to_update:
database.execute(update(TableEpisodes), episodes_to_update) try:
except IntegrityError as e: database.execute(update(TableEpisodes)
logging.error(f"BAZARR cannot update episodes because of {e}") .values(updated_episode)
else: .where(TableEpisodes.sonarrEpisodeId == updated_episode['sonarrEpisodeId']))
for updated_episode in episodes_to_update: except IntegrityError as e:
logging.error(f"BAZARR cannot update episodes because of {e}")
else:
store_subtitles(updated_episode['path'], path_mappings.path_replace(updated_episode['path'])) store_subtitles(updated_episode['path'], path_mappings.path_replace(updated_episode['path']))
if send_event: if send_event:
@ -107,12 +109,12 @@ def sync_episodes(series_id, send_event=True):
# Insert new episodes in DB # Insert new episodes in DB
if len(episodes_to_add): if len(episodes_to_add):
try: for added_episode in episodes_to_add:
database.execute(insert(TableEpisodes).values(episodes_to_add)) try:
except IntegrityError as e: database.execute(insert(TableEpisodes).values(added_episode))
logging.error(f"BAZARR cannot insert episodes because of {e}") except IntegrityError as e:
else: logging.error(f"BAZARR cannot insert episodes because of {e}")
for added_episode in episodes_to_add: else:
store_subtitles(added_episode['path'], path_mappings.path_replace(added_episode['path'])) store_subtitles(added_episode['path'], path_mappings.path_replace(added_episode['path']))
if send_event: if send_event:

Loading…
Cancel
Save