Skip to content

Commit

Permalink
adding missing ; and update docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
vianeyBE committed Apr 25, 2024
1 parent fe34207 commit a59f2f7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/python/ensembl/genes/metadata/database/write2db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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",
Expand All @@ -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")
Expand Down Expand Up @@ -200,4 +209,4 @@ def main():
print(query)

if __name__ == "__main__":
main()
main()

0 comments on commit a59f2f7

Please sign in to comment.