File size: 1,344 Bytes
a61f95d b6ee5b6 a61f95d b6ee5b6 a61f95d b6ee5b6 a61f95d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
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 |