Vaibhav84 commited on
Commit
889e2a3
·
1 Parent(s): 3ad06d7
Files changed (4) hide show
  1. DbConnection.py +19 -0
  2. RemoveSkills.py +7 -4
  3. SampleCall.py +30 -0
  4. SampleDbConnection.py +23 -0
DbConnection.py CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  class DbConnection:
2
  def GetDbConnection():
3
  db_params = {
@@ -7,4 +11,19 @@ class DbConnection:
7
  'password': '5omRLogf9Kdas3zoBFPCT9yrCGU4IbEX',
8
  }
9
  return db_params
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
 
1
+
2
+ import pymysql
3
+
4
+ timeout = 10
5
  class DbConnection:
6
  def GetDbConnection():
7
  db_params = {
 
11
  'password': '5omRLogf9Kdas3zoBFPCT9yrCGU4IbEX',
12
  }
13
  return db_params
14
+ def GetMySQLDbConnection():
15
+ connection = pymysql.connect(
16
+ charset="utf8mb4",
17
+ connect_timeout=timeout,
18
+ cursorclass=pymysql.cursors.DictCursor,
19
+ db="defaultdb",
20
+ host="mysql-anu-xboxgames1900-aebf.a.aivencloud.com",
21
+ password="AVNS_TGfs_uHRKteMjB9pFnq",
22
+ read_timeout=timeout,
23
+ port=25227,
24
+ user="avnadmin",
25
+ write_timeout=timeout,
26
+ )
27
+ return connection
28
+
29
 
RemoveSkills.py CHANGED
@@ -1,12 +1,15 @@
1
  import psycopg2
 
 
2
  class RemoveSkill:
3
  def RemoveSkillDetails(db_params, SkillName):
4
- conn = psycopg2.connect(**db_params)
5
- cursor = conn.cursor()
 
6
  print("Removing Skills " + SkillName)
7
  query = "update skillmaster set weightage = 0 where upper(skilldetails) = (%s)"
8
  params = (SkillName.upper(),)
9
  cursor.execute(query, params)
10
- conn.commit()
11
  cursor.close()
12
- conn.close()
 
1
  import psycopg2
2
+ import pymysql
3
+ from DbConnection import DbConnection
4
  class RemoveSkill:
5
  def RemoveSkillDetails(db_params, SkillName):
6
+ #conn = psycopg2.connect(**db_params)
7
+ conn1 = DbConnection.GetMySQLDbConnection()
8
+ cursor = conn1.cursor()
9
  print("Removing Skills " + SkillName)
10
  query = "update skillmaster set weightage = 0 where upper(skilldetails) = (%s)"
11
  params = (SkillName.upper(),)
12
  cursor.execute(query, params)
13
+ conn1.commit()
14
  cursor.close()
15
+ conn1.close()
SampleCall.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import os
3
+
4
+ # URL of the API endpoint
5
+ url = "https://vaibhav84-resumeapi.hf.space/UploadJobDescription/"
6
+
7
+ # Path to the file you want to upload
8
+ file_path = "d:/hug/job_desc_front_end_engineer.pdf"
9
+ file_name = os.path.basename(file_path)
10
+
11
+ # Open the file in binary mode
12
+ with open(file_path, "rb") as file:
13
+ # Prepare the file to be sent in the request
14
+ files = {"file": (file_path, file)}
15
+
16
+ # Additional parameters for the request
17
+ params = {"FileName": file_name} # Adjust FileName if necessary
18
+
19
+ # Make the POST request
20
+ response = requests.post(url, files=files, params=params)
21
+
22
+ # Check if the request was successful (status code 200)
23
+ if response.status_code == 200:
24
+ print("Job description uploaded successfully.")
25
+ # Print the response from the API
26
+ print(response.text)
27
+ else:
28
+ print("Failed to upload job description.")
29
+ print("Status code:", response.status_code)
30
+ print("Response:", response.text)
SampleDbConnection.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pymysql
2
+
3
+ timeout = 10
4
+ db_params = {}
5
+ connection = pymysql.connect(
6
+ charset="utf8mb4",
7
+ connect_timeout=timeout,
8
+ cursorclass=pymysql.cursors.DictCursor,
9
+ db="defaultdb",
10
+ host="mysql-anu-xboxgames1900-aebf.a.aivencloud.com",
11
+ password="AVNS_TGfs_uHRKteMjB9pFnq",
12
+ read_timeout=timeout,
13
+ port=25227,
14
+ user="avnadmin",
15
+ write_timeout=timeout,
16
+ )
17
+
18
+ try:
19
+ cursor = connection.cursor()
20
+ cursor.execute("SELECT * FROM skillmaster")
21
+ print(cursor.fetchall())
22
+ finally:
23
+ connection.close()