From a59f2f74d99da54560809fa089b55428f0a12d4e Mon Sep 17 00:00:00 2001 From: Vianey Date: Thu, 25 Apr 2024 19:54:18 +0100 Subject: [PATCH] adding missing ; and update docstrings --- .../ensembl/genes/metadata/database/write2db.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/python/ensembl/genes/metadata/database/write2db.py b/src/python/ensembl/genes/metadata/database/write2db.py index a668681..1fd81a5 100644 --- a/src/python/ensembl/genes/metadata/database/write2db.py +++ b/src/python/ensembl/genes/metadata/database/write2db.py @@ -13,6 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +""" +Script to create mysql queries (insert and update) given a json file as input + +Raises: + ValueError: rise and exception when key are missing of the data is not properly formatted + + Returns: + str: MySQl queries +""" #import pymysql import json @@ -115,7 +124,7 @@ def update_query(data_dict, table_name, table_conf): update_values = ','.join(update_list) - return f"UPDATE {table_name} SET {update_values} WHERE {condition}" + return f"UPDATE {table_name} SET {update_values} WHERE {condition} ;" def create_query(data_dict, table_name, update, table_conf): """ @@ -148,7 +157,7 @@ def main(): "data_files": {"method": "per_col","dkey": "run_id", "ukey": "file_id"}, "align": {"method": "per_col", "dkey": "run_id", "ukey": "None"} } - + db_params = { "host":"mysql-ens-genebuild-prod-1", "user":"ensadmin", @@ -164,7 +173,7 @@ def main(): description="Write JSON files to DB") parser.add_argument("--file-path", type=str, - help="JSON file containing data to insert/update in a DB") + help="Path to the JSON file containing data to insert/update in a DB") #parser.add_argument('--table-config', type=str, # help="file with the configuration of the DB") @@ -200,4 +209,4 @@ def main(): print(query) if __name__ == "__main__": - main() + main() \ No newline at end of file