ucampostgresvro 0.2.1__py3-none-any.whl → 0.2.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ucampostgresvro/DBA.py CHANGED
@@ -73,7 +73,7 @@ class DB:
73
73
  new_crsid: str,
74
74
  name: str,
75
75
  table_name: str = DEFAULT_TABLES.get("user"),
76
- ) -> bool:
76
+ ) -> int:
77
77
  """Updation of the vrauser.
78
78
 
79
79
  Args:
@@ -83,18 +83,18 @@ class DB:
83
83
  table_name (str): table name of the user.
84
84
 
85
85
  Returns:
86
- bool: True for the success and False for the failure.
86
+ int: primary key of the user which is updated.
87
87
  """
88
88
  with self.connection:
89
89
  try:
90
90
  self.cursor.execute(
91
- f"UPDATE {table_name} SET crsid ='{new_crsid}' , name='{name}' WHERE crsid='{old_crsid}';"
91
+ f"UPDATE {table_name} SET crsid ='{new_crsid}' , name='{name}' WHERE crsid='{old_crsid}' RETURNING id;"
92
92
  )
93
93
  LOG.info(f"INFO: {table_name} update successful for CRSID {old_crsid}")
94
- return True
94
+ return self.cursor.fetchone()[0]
95
95
  except Exception as e:
96
96
  LOG.error(f"Error: {table_name} Updating : {e}")
97
- return False
97
+ raise DbException(f"Error: {table_name} Updating : {e}")
98
98
 
99
99
  def remove_vrauser(
100
100
  self, crsid: str, table_name: str = DEFAULT_TABLES.get("user")
@@ -245,7 +245,7 @@ class DB:
245
245
  old_deployment_id: str,
246
246
  new_deployment_id: str,
247
247
  table_name: str = DEFAULT_TABLES.get("deploymentid"),
248
- ) -> bool:
248
+ ) -> int:
249
249
  """Updation of the the deployment ID in deployment table.
250
250
 
251
251
  Args:
@@ -254,22 +254,22 @@ class DB:
254
254
  table_name (str): table name of the deploymentid.
255
255
 
256
256
  Returns:
257
- bool: True for the success and False for the failure.
257
+ int: primary key of the deployment.
258
258
  """
259
259
  with self.connection:
260
260
  try:
261
261
  self.cursor.execute(
262
262
  f"UPDATE {table_name} SET deploymentID ='{new_deployment_id}' \
263
- WHERE deploymentID='{old_deployment_id}';"
263
+ WHERE deploymentID='{old_deployment_id}' RETURNING id;"
264
264
  )
265
265
  LOG.info(
266
266
  f"INFO: deployment ID of {old_deployment_id} updated successfully with \
267
267
  {new_deployment_id} in table {table_name} ."
268
268
  )
269
- return True
269
+ return self.cursor.fetchone()[0]
270
270
  except Exception as e:
271
271
  LOG.error(f"Error: deployment ID update for table {table_name}: {e}")
272
- return False
272
+ raise DbException(f"Error: deployment ID update for table {table_name}: {e}")
273
273
 
274
274
  def remove_deployment_id(
275
275
  self, deployment_id: str, table_name: str = DEFAULT_TABLES.get("deploymentid")
@@ -430,7 +430,7 @@ class DB:
430
430
  new_paid_by: int,
431
431
  new_amount: float,
432
432
  table_name: str = DEFAULT_TABLES.get("proj"),
433
- ) -> bool:
433
+ ) -> int:
434
434
  """Updation of the the project detail in project table
435
435
 
436
436
  Args:
@@ -441,22 +441,22 @@ class DB:
441
441
  table_name (str): table name of the project.
442
442
 
443
443
  Returns:
444
- bool: True for the success and False for the failure.
444
+ int: Primary key of the project.
445
445
  """
446
446
  with self.connection:
447
447
  try:
448
448
  self.cursor.execute(
449
449
  f"UPDATE {table_name} SET \
450
450
  project_number ='{new_project_number}', paid_by='{new_paid_by}', amount='{new_amount}' \
451
- WHERE id='{project_id}';"
451
+ WHERE id='{project_id}' RETURNING id;"
452
452
  )
453
453
  LOG.info(
454
454
  f"INFO: Updation of the project {project_id} has been peformed successfully"
455
455
  )
456
- return True
456
+ return self.cursor.fetchone()[0]
457
457
  except Exception as e:
458
458
  LOG.error(f"Error: Project Updating in table {table_name} : {e}")
459
- return False
459
+ raise DbException(f"Error: Project Updating in table {table_name} : {e}")
460
460
 
461
461
  def remove_project(
462
462
  self, project_id: int, table_name: str = DEFAULT_TABLES.get("proj")
@@ -609,7 +609,7 @@ class DB:
609
609
  new_paid_by: int,
610
610
  new_amount: float,
611
611
  table_name: str = DEFAULT_TABLES.get("grant"),
612
- ) -> bool:
612
+ ) -> int:
613
613
  """ "Updation of the the grant detail in grant table
614
614
 
615
615
  Args:
@@ -620,23 +620,26 @@ class DB:
620
620
  table_name (str): table name of the grant.
621
621
 
622
622
  Returns:
623
- bool: True for the success and False for the failure.
623
+ int: Primary key of the Grant.
624
624
  """
625
625
  with self.connection:
626
626
  try:
627
627
  self.cursor.execute(
628
628
  f"UPDATE {table_name} SET grant_number ='{new_grant}', paid_by='{new_paid_by}', \
629
- amount='{new_amount}' WHERE id='{grant_id}';"
629
+ amount='{new_amount}' WHERE id='{grant_id}' RETURNING id;"
630
630
  )
631
631
  LOG.info(
632
632
  f"INFO: Updation of the grant {grant_id} has been performed successfully."
633
633
  )
634
- return True
634
+ return self.cursor.fetchone()[0]
635
635
  except Exception as e:
636
636
  LOG.error(
637
637
  f"Error: grant Updating of '{grant_id}' in table '{table_name}': {e}"
638
638
  )
639
- return False
639
+ raise DbException(
640
+ f"Error: grant Updating of '{grant_id}' in table '{table_name}': {e}"
641
+ )
642
+
640
643
 
641
644
  def remove_grant(
642
645
  self, grant_id: int, table_name: str = DEFAULT_TABLES.get("grant")
@@ -815,7 +818,7 @@ class DB:
815
818
  new_grant_id: Optional[int] = None,
816
819
  new_project_id: Optional[int] = None,
817
820
  table_name: str = DEFAULT_TABLES.get("costing"),
818
- ) -> bool:
821
+ ) -> int:
819
822
  """Updation of the costing database entry.
820
823
 
821
824
  Args:
@@ -830,7 +833,7 @@ class DB:
830
833
  DbException: Exception for the provided inputs.
831
834
 
832
835
  Returns:
833
- bool: True for the success and False for the failure.
836
+ int: Primary key of the costing.
834
837
  """
835
838
  if new_grant_id and new_project_id:
836
839
  raise DbException(
@@ -843,12 +846,12 @@ class DB:
843
846
  self.cursor.execute(
844
847
  f"UPDATE {table_name} SET \
845
848
  deployment_id ='{new_deployment_id}', type='{new_typee}', project_id={project_id}, \
846
- grant_id={grant_id} WHERE id='{old_costing_id}';"
849
+ grant_id={grant_id} WHERE id='{old_costing_id}' RETURNING id;"
847
850
  )
848
851
  LOG.info(
849
852
  "INFO: updation of the costing has been performed successfully."
850
853
  )
851
- return True
854
+ return self.cursor.fetchone()[0]
852
855
  except Exception as e:
853
856
  LOG.error(
854
857
  f"Error: Updation of costing has failed in table '{table_name}': \n {e}"
@@ -1 +1 @@
1
- VERSION = "0.2.0"
1
+ VERSION = "0.2.2"
@@ -37,7 +37,7 @@ def main():
37
37
  if not utils.pre_setupconfig(db_params):
38
38
  raise DbException("ERROR: Tables are not created successfully")
39
39
 
40
- print(db.insert_vrauser("ll221", "leny"))
40
+ # print(db.insert_vrauser("ll221", "leny"))
41
41
  # print(db.get_vrauser("ll220"))
42
42
  # print(db.get_vrauser_primary_key("ll220"))
43
43
  # db.update_vrauser("ll220", "bda20", 'Ben Argyle')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: ucampostgresvro
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: To connect with postgresql for the billing report
5
5
  Author: Ishan Mahajan
6
6
  Author-email: mahanishanmahajan@gmail.com
@@ -1,6 +1,6 @@
1
- ucampostgresvro/DBA.py,sha256=x795bE2kUOiDc1274bFXO1dMlQlvGQXZayirE0TGlZM,38597
2
- ucampostgresvro/__init__.py,sha256=w9Iw7QVvd8lme2wKwEbCo5IgetVjSfFBOOYAcA_Q0Ns,18
3
- ucampostgresvro/__main__.py,sha256=KzZTQ308dHN0OuvxObUhCdGJz2sbb8iFr-wOP6_iSMg,4128
1
+ ucampostgresvro/DBA.py,sha256=Bz3Ql-LtM-BUiQTWGww-Gjl6S3geTzifiZVxjN2Pcb4,38957
2
+ ucampostgresvro/__init__.py,sha256=qleN2zQctO8stGYcfqFUyavqMP9pxdKBbwgZWyKxPWQ,18
3
+ ucampostgresvro/__main__.py,sha256=87ArORk2ViXoUWCK7zyGL-ly4jpbP_JqMMLKio4K4wY,4130
4
4
  ucampostgresvro/ca.crt,sha256=pVDr3AsvwCqJ36JTifsAzIiS2ve_fWC1CBfVI0cnVmY,1135
5
5
  ucampostgresvro/exceptions.py,sha256=XVi8Sk_gg3VE4ryTtiYOnGbmCPIsfFt2AE5sOoqQDuI,39
6
6
  ucampostgresvro/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -10,7 +10,7 @@ ucampostgresvro/tests/test_DB.py,sha256=lye6NLUS2k7W7Kr083fQ5HDUD5hMMUqvIXL2xbNo
10
10
  ucampostgresvro/tests/utils.py,sha256=lpcvf6HPOOtxAwSwvoAUhil1zQ6Qfr0ZILa0qDVdES0,3722
11
11
  ucampostgresvro/tools.py,sha256=Y8MUK1lIG10A-724yrhve8LfjQUmFwpqi19UIO5DeuI,153
12
12
  ucampostgresvro/utils.py,sha256=QYhWaBaxGn-yKEGm___3-7RitbIWwICTplbz7LyKgLE,8543
13
- ucampostgresvro-0.2.1.dist-info/LICENSE,sha256=CVTj8C-BHEJjzYlYtHnfykxKkfmk-ImXOs5rcMgXebY,1094
14
- ucampostgresvro-0.2.1.dist-info/METADATA,sha256=xQeFtb89nyd4YJuY7SKQONgjZBhM-1WJ3i3HFbejw0c,9791
15
- ucampostgresvro-0.2.1.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
16
- ucampostgresvro-0.2.1.dist-info/RECORD,,
13
+ ucampostgresvro-0.2.2.dist-info/LICENSE,sha256=CVTj8C-BHEJjzYlYtHnfykxKkfmk-ImXOs5rcMgXebY,1094
14
+ ucampostgresvro-0.2.2.dist-info/METADATA,sha256=NLZ5tNdr7nQfpzYR2cKjxWQGCndZZv32rY0f5rUDpRQ,9791
15
+ ucampostgresvro-0.2.2.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
16
+ ucampostgresvro-0.2.2.dist-info/RECORD,,