Unverified Commit 29dd1815 authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

catch individual statement when creating sql

parent 190b1ccb
Pipeline #17991 passed with stages
in 1 minute and 57 seconds
......@@ -262,28 +262,44 @@ def _create_audio_snippet_entry(record, mariadb_cursor) -> list:
snippet_record['mimetype'] = 'audio/mpeg'
snippet_record['uri'] = \
'.'.join(snippet_record['uri'].split('.')[0:-1]) + '-intro.mp3'
result_entities = _create_entities_entry(snippet_record, mariadb_cursor)
results.append((record, result_entities, 'audio snippet', 'entities'))
result_metadata = _create_metadata_entry(snippet_record, mariadb_cursor)
results.append((record, result_metadata, 'audio snippet', 'metadata'))
try:
result_entities = _create_entities_entry(snippet_record, mariadb_cursor)
results.append((record, result_entities, 'audio snippet', 'entities'))
except Exception as ex:
logging.error(f'Exception when writing table `entities` '
f'for audio snippet belonging to record {record["sig"]}: {str(ex)}')
results.append((record, False, 'audio snippet', 'entities'))
try:
result_metadata = _create_metadata_entry(snippet_record, mariadb_cursor)
results.append((record, result_metadata, 'audio snippet', 'metadata'))
except Exception as ex:
logging.error(f'Exception when writing table `metadata` '
f'for audio snippet belonging to record {record["sig"]}: {str(ex)}')
results.append((record, False, 'audio snippet', 'metadata'))
return results
def _write_values_in_db(mariadb_cursor, record_values_for_db) -> list:
results = []
try:
for record in record_values_for_db:
for record in record_values_for_db:
try:
res_entities = _create_entities_entry(record, mariadb_cursor)
results.append((record, res_entities, 'record', 'entities'))
except Exception as ex:
logging.error(f'Exception when writing table `entities` '
f'for record {record["sig"]}: {str(ex)}')
results.append((record, False, 'record', 'entities'))
try:
res_metadata = _create_metadata_entry(record, mariadb_cursor)
results.append((record, res_metadata, 'record', 'metadata'))
if _has_audio_snippet(record):
results.extend(_create_audio_snippet_entry(record, mariadb_cursor))
return results
except Exception as ex:
status = 'Exception: ' + str(ex)
logging.error(status)
return []
except Exception as ex:
logging.error(f'Exception when writing table `metadata` '
f'for record {record["sig"]}: {str(ex)}')
results.append((record, False, 'record', 'entities'))
if _has_audio_snippet(record):
results.extend(_create_audio_snippet_entry(record, mariadb_cursor))
return results
class MediametadataToDB:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment