from psycopg2 import sql from DbConnection import DbConnection class AddSkill: def AddSkillDetails(skills): returnMsg='' details = skills.split(',') skill_details = details[0] skill_type = details [1] skill_score1 = details[2] weightage = -2 is_active = True conn = DbConnection.GetMySQLDbConnection() cursor = conn.cursor() print("Adding Skill " + skill_details) query = "SELECT skillid FROM skillmaster WHERE upper(skillDetails) IN (%s)" params = (skill_details.upper(),) # Replace 'Test' with your actual variable or user input cursor.execute(query, params) if cursor.rowcount == 0: insert_query = sql.SQL("""INSERT INTO SkillMaster (SkillDetails, SkillType, Weightage, IsActive, skill_score) VALUES (%s, %s, %s, %s, %s) RETURNING SkillID""") cursor.execute(insert_query, (skill_details, skill_type, weightage, is_active, skill_score1)) conn.commit() returnMsg = 'Skill Added successfully' else: returnMsg = 'Skill Already in DB' # Close the cursor and connection cursor.close() # Close the connection conn.close() print(returnMsg) return returnMsg