diff options
-rw-r--r-- | scripts/load_phenotypes_to_db.py | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/scripts/load_phenotypes_to_db.py b/scripts/load_phenotypes_to_db.py index 766001a..8143d74 100644 --- a/scripts/load_phenotypes_to_db.py +++ b/scripts/load_phenotypes_to_db.py @@ -323,29 +323,21 @@ if __name__ == "__main__": # How do you check for a table lock? # https://oracle-base.com/articles/mysql/mysql-identify-locked-tables # `SHOW OPEN TABLES LIKE 'Publish%';` - logger.debug( - ("Locking database tables for the connection:" - "\n\t- %s\n\t- %s\n\t- %s\n\t- %s\n\t- %s\n"), + _db_tables_ = ( "Publication", + "Phenotype", "PublishXRef", "PublishData", "PublishSE", "NStrain") + + logger.debug( + ("Locking database tables for the connection:" + + "".join("\n\t- %s" for _ in _db_tables_) + "\n"), + *_db_tables_) cursor.execute(# Lock the tables to avoid race conditions - "LOCK TABLES " - "Publication WRITE, " - "PublishXRef WRITE, " - "PublishData WRITE, " - "PublishSE WRITE, " - "NStrain WRITE") - try: - return load_data(conn, jobs.job(jobs_conn, args.job_id)) - except jobs.jobs.JobNotFound as _jne: - logger.error("Could not find job with ID: %s", args.job_id) - except Exception as _exc: - logger.error("Loading failed with general exception!", - exc_info=True, - stack_info=True) + "LOCK TABLES " + ", ".join( + f"{_table} WRITE" for _table in _db_tables_)) logger.debug("Unlocking all database tables.") cursor.execute("UNLOCK TABLES") |