File size: 2,719 Bytes
a61f95d
b6ee5b6
3b2ceca
55d2736
b6ee5b6
a61f95d
b6ee5b6
a61f95d
 
 
 
 
 
 
b6ee5b6
a61f95d
 
 
 
 
 
 
01cb679
2236484
a61f95d
 
 
 
 
 
a647161
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a61f95d
 
 
 
 
55d2736
 
 
66bde0d
 
 
 
 
 
 
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71

from psycopg2 import sql
import pymysql
import pandas as pd
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 = ("""INSERT INTO skillmaster (SkillDetails, SkillType, Weightage, IsActive, skill_score) 
                        VALUES (%s, %s, %s, %s, %s)""")
            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
    def UpdateSkillDetails(skills):
        returnMsg=''
        details = skills.split(',')
        skill_details = details[0]
        weightage = details [1]
        is_active = True
        conn = DbConnection.GetMySQLDbConnection()
        cursor = conn.cursor()
        print("Updating 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:    
            returnMsg = 'Skill Not in DB'
        else:            
            update_query = ("""UPDATE skillmaster set weightage = %s where upper(skilldetails) = %s""")
            cursor.execute(update_query, (weightage, skill_details.upper()))
            conn.commit()
            returnMsg = 'Skill Updated successfully'
             
        # Close the cursor and connection
        cursor.close()
        # Close the connection
        conn.close()
        print(returnMsg)   
        return returnMsg
    def GetSkillDetails():
        conn = DbConnection.GetMySQLDbConnection()
        cursor = conn.cursor()
        cursor.execute("SELECT * FROM skillmaster")
        cursor.close()
        # Close the connection
        conn.close()
        return cursor.fetchall()