ucampostgresvro 0.1.2__py3-none-any.whl → 0.2.1__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.
@@ -1 +1 @@
1
- VERSION = "0.1.2"
1
+ VERSION = "0.2.0"
@@ -1,6 +1,7 @@
1
1
  import logging
2
2
  import sys
3
3
 
4
+ # from datetime import datetime
4
5
  from ucampostgresvro import VERSION, utils
5
6
  from ucampostgresvro.DBA import DB
6
7
  from ucampostgresvro.exceptions import DbException
@@ -36,47 +37,76 @@ def main():
36
37
  if not utils.pre_setupconfig(db_params):
37
38
  raise DbException("ERROR: Tables are not created successfully")
38
39
 
39
- # db.insert_vrauser("ll220", "len")
40
+ print(db.insert_vrauser("ll221", "leny"))
40
41
  # print(db.get_vrauser("ll220"))
42
+ # print(db.get_vrauser_primary_key("ll220"))
41
43
  # db.update_vrauser("ll220", "bda20", 'Ben Argyle')
42
44
  # print(db.get_vrauser())
43
45
  # db.remove_vrauser('bda20')
46
+ # print(db.get_vrauser_by_id(2))
44
47
  # print(db.get_vrauser())
45
48
 
46
49
  # db.insert_deployment_id("1231ee112ad11212")
50
+ # print(db.get_deployment_id("1231ee112ad11212"))
51
+ # print(db.get_deployment_id_primary_key("1231ee112ad11212"))
47
52
  # db.update_deployment_id("1231ee112ad11212", "1231a")
48
53
  # print(db.get_deployment_id("1231a"))
49
54
  # db.remove_deployment_id('1231a')
55
+ # print(db.get_deployment_id())
50
56
  # db.insert_deployment_id("123")
51
57
  # print(db.get_deployment_id())
58
+ # print(db.get_deployment_id_by_id(2))
59
+ # print(db.get_deployment_id_primary_key("123"))
52
60
 
53
- # print(db.get_project())
54
- # db.insert_project("0001",1,100.0)
55
61
  # db.insert_project("0101",2,100.0)
56
- # db.update_project("0001", "0002", 1, 200)
57
- # db.remove_project("0002")
58
- # db.insert_project("0001",1,100.0)
59
- # db.insert_project("0002",1,200.0)
60
- # print(db.get_project("0002",1,200))
62
+ # db.insert_project("0001",2,100.0)
63
+ # print(db.get_project())
64
+ # db.update_project(2, "0002", 2, 200)
65
+ # print(db.get_project())
66
+ # db.remove_project(1)
67
+ # print(db.get_project())
68
+ # db.insert_project("2001",2,100.0)
69
+ # db.insert_project("2003",2,200.0)
70
+ # db.insert_project("2001",2,100.0)
71
+ # print(db.get_project("2001"))
72
+ # print(db.get_project_by_id(6))
73
+ # print(db.get_project_primary_key("2001"))
74
+ # print(db.get_project_primary_key("2001", datetime(2025, 1, 22, 15, 55, 25, 95698)))
75
+ # print(db.get_project())
61
76
 
62
77
  # print(db.get_grant())
63
- # db.insert_grant("0001",1,100.0)
64
- # db.update_grant("0001", "0002", 1, 200)
78
+ # db.insert_grant("0001",2,100.0)
79
+ # print(db.get_grant())
80
+ # db.update_grant(2, "0002", 2, 200)
65
81
  # print(db.get_grant())
66
- # db.remove_grant("0002")
82
+ # db.insert_grant("2001",2,100.0)
83
+ # db.insert_grant("2003",2,200.0)
84
+ # db.insert_grant("2001",2,100.0)
67
85
  # print(db.get_grant())
68
- # db.insert_grant("0001",1,100.0)
69
- # db.insert_grant("0002",1,200.0)
70
- # print(db.get_grant("0002",1,200))
86
+ # print(db.get_grant())
87
+ # print(db.get_grant("2001"))
88
+ # print(db.get_grant_primary_key("2001"))
89
+ # print(db.get_grant_by_id(5))
90
+ # print(db.get_grant_primary_key("2001",
91
+ # datetime(2025, 1, 22, 18, 17, 25, 95698)
92
+ # )
93
+ # )
94
+ # print(db.get_project())
95
+ # db.remove_grant(1)
71
96
 
97
+ # db.insert_costing(2, "Initial Resource", project_id=2, grant_id=None)
98
+ # db.insert_costing(2, "Initial Resource", project_id=None, grant_id=2)
72
99
  # print(db.get_costing())
73
- # db.insert_costing(1, "Initial Resource", project_id=2, grant_id=None)
74
- # db.insert_costing(1, "Initial Resource", project_id=None, grant_id=1)
75
- # db.update_costing(1, "Duration Expansion", old_grant_id=None,
76
- # old_project_id=2, grant_id=None, project_id=2)
77
100
  # print(db.get_costing())
101
+ # print(db.get_costing(2, "Initial Resource", 2)) # project
102
+ # print(db.get_costing(2, "Initial Resource", None, 2)) # Grant
103
+ # print(db.get_costing(3, "Duration Expansion", None, 2)) # Grant
104
+ # # print(db.get_costing_primary_key(2, "Initial Resource", 2)) # project
105
+ # print(db.get_costing_primary_key(2, "Initial Resource", None, 2)) #Grant
106
+ # db.update_costing(3, 2, "Duration Expansion", new_grant_id=None, new_project_id=2)
78
107
  # print(db.get_costing())
79
- # db.remove_costing(1, "Duration Expansion", 4, None)
108
+ # print(db.get_costing_by_id(3))
109
+ # db.remove_costing(4)
80
110
  # print(db.get_costing())
81
111
 
82
112
  db.closedb()
@@ -2,9 +2,9 @@ import os
2
2
 
3
3
 
4
4
  db_params = {
5
- "dbname": os.environ['POSTGRES_DB'],
6
- "user": os.environ['POSTGRES_USER'],
7
- "password": os.environ['POSTGRES_PASSWORD'],
8
- "host": os.environ['POSTGRES_HOST'],
9
- "port": os.environ['POSTGRES_PORT']
5
+ "dbname": os.environ["POSTGRES_DB"],
6
+ "user": os.environ["POSTGRES_USER"],
7
+ "password": os.environ["POSTGRES_PASSWORD"],
8
+ "host": os.environ["POSTGRES_HOST"],
9
+ "port": os.environ["POSTGRES_PORT"],
10
10
  }
@@ -38,6 +38,14 @@ def test_user_fetchall(user_db_fixture):
38
38
  assert info[1][1] == "im532"
39
39
 
40
40
 
41
+ def test_user_fetch_by_id(user_db_fixture):
42
+ db = user_db_fixture
43
+ db.insert_vrauser("im530", "Ishan", tables.get("user"))
44
+ db.insert_vrauser("im532", "Ishan", tables.get("user"))
45
+ info = db.get_vrauser_by_id(2, tables.get("user"))
46
+ assert info[1] == "im532"
47
+
48
+
41
49
  def test_user_fetch_one(user_db_fixture):
42
50
  db = user_db_fixture
43
51
  db.insert_vrauser("im530", "Ishan", tables.get("user"))
@@ -47,6 +55,14 @@ def test_user_fetch_one(user_db_fixture):
47
55
  assert info[0][1] == "im530"
48
56
 
49
57
 
58
+ def test_user_fetch_primary_key_crsid(user_db_fixture):
59
+ db = user_db_fixture
60
+ db.insert_vrauser("im530", "Ishan", tables.get("user"))
61
+ db.insert_vrauser("im532", "Ishan", tables.get("user"))
62
+ info = db.get_vrauser_primary_key("im532", tables.get("user"))
63
+ assert info == 2
64
+
65
+
50
66
  def test_deployment_insertion(deploymentid_db_fixture):
51
67
  db = deploymentid_db_fixture
52
68
  result = db.insert_deployment_id("121212", tables.get("deploymentid"))
@@ -84,6 +100,14 @@ def test_deployment_fetchall(deploymentid_db_fixture):
84
100
  assert info[1][1] == "1256"
85
101
 
86
102
 
103
+ def test_deployment_fetch_by_id(deploymentid_db_fixture):
104
+ db = deploymentid_db_fixture
105
+ db.insert_deployment_id("1212", tables.get("deploymentid"))
106
+ db.insert_deployment_id("1256", tables.get("deploymentid"))
107
+ info = db.get_deployment_id_by_id(2, tables.get("deploymentid"))
108
+ assert info[1] == "1256"
109
+
110
+
87
111
  def test_deployment_fetch_one(deploymentid_db_fixture):
88
112
  db = deploymentid_db_fixture
89
113
  db.insert_deployment_id("1212", tables.get("deploymentid"))
@@ -93,6 +117,14 @@ def test_deployment_fetch_one(deploymentid_db_fixture):
93
117
  assert info[0][1] == "1256"
94
118
 
95
119
 
120
+ def test_deployment_fetch_primary_key_deployment(deploymentid_db_fixture):
121
+ db = deploymentid_db_fixture
122
+ db.insert_deployment_id("1212", tables.get("deploymentid"))
123
+ db.insert_deployment_id("1256", tables.get("deploymentid"))
124
+ info = db.get_deployment_id_primary_key("1256", tables.get("deploymentid"))
125
+ assert info == 2
126
+
127
+
96
128
  def test_proj_insertion(project_db_fixture):
97
129
  db = project_db_fixture
98
130
  db.insert_vrauser("im530", "Ishan", tables.get("user"))
@@ -109,13 +141,13 @@ def test_proj_update(project_db_fixture):
109
141
  users = db.get_vrauser(None, None, tables.get("user"))
110
142
  db.insert_project("123abc", users[0][0], 100.0, tables.get("proj"))
111
143
  result = db.update_project(
112
- "123abc", "9876xyz", users[0][0], 220.0, tables.get("proj")
144
+ 1, "9876xyz", users[0][0], 220.0, tables.get("proj")
113
145
  )
114
146
  info = db.get_project(None, tables.get("proj"))
115
147
  assert len(info) == 1
116
148
  assert result
117
- assert info[0][1] == "9876xyz"
118
- assert info[0][3] == 220.0
149
+ assert info[0][2] == "9876xyz"
150
+ assert info[0][4] == 220.0
119
151
 
120
152
 
121
153
  def test_proj_remove(project_db_fixture):
@@ -123,8 +155,8 @@ def test_proj_remove(project_db_fixture):
123
155
  db.insert_vrauser("im530", "Ishan", tables.get("user"))
124
156
  users = db.get_vrauser(None, None, tables.get("user"))
125
157
  db.insert_project("123abc", users[0][0], 100.0, tables.get("proj"))
126
- info = db.get_project(None, tables.get("proj"))
127
- result = db.remove_project("123abc", tables.get("proj"))
158
+ prj = db.get_project(None, tables.get("proj"))
159
+ result = db.remove_project(prj[0][0], tables.get("proj"))
128
160
  info = db.get_project(None, tables.get("proj"))
129
161
  assert result
130
162
  assert len(info) == 0
@@ -138,8 +170,8 @@ def test_proj_fetchall(project_db_fixture):
138
170
  db.insert_project("123xyz", users[0][0], 200.0, tables.get("proj"))
139
171
  info = db.get_project(None, tables.get("proj"))
140
172
  assert len(info) == 2
141
- assert info[0][1] == "123abc"
142
- assert info[1][1] == "123xyz"
173
+ assert info[0][2] == "123abc"
174
+ assert info[1][2] == "123xyz"
143
175
 
144
176
 
145
177
  def test_proj_fetch_one(project_db_fixture):
@@ -150,7 +182,27 @@ def test_proj_fetch_one(project_db_fixture):
150
182
  db.insert_project("123xyz", users[0][0], 200.0, tables.get("proj"))
151
183
  info = db.get_project("123xyz", tables.get("proj"))
152
184
  assert len(info) == 1
153
- assert info[0][1] == "123xyz"
185
+ assert info[0][2] == "123xyz"
186
+
187
+
188
+ def test_proj_fetch_by_id(project_db_fixture):
189
+ db = project_db_fixture
190
+ db.insert_vrauser("im530", "Ishan", tables.get("user"))
191
+ users = db.get_vrauser(None, None, tables.get("user"))
192
+ db.insert_project("123abc", users[0][0], 100.0, tables.get("proj"))
193
+ db.insert_project("123xyz", users[0][0], 200.0, tables.get("proj"))
194
+ info = db.get_project_by_id(2, tables.get("proj"))
195
+ assert info[2] == "123xyz"
196
+
197
+
198
+ def test_proj_fetch_primary_key(project_db_fixture):
199
+ db = project_db_fixture
200
+ db.insert_vrauser("im530", "Ishan", tables.get("user"))
201
+ users = db.get_vrauser(None, None, tables.get("user"))
202
+ db.insert_project("123abc", users[0][0], 100.0, tables.get("proj"))
203
+ db.insert_project("123xyz", users[0][0], 200.0, tables.get("proj"))
204
+ info = db.get_project_primary_key("123xyz", None, tables.get("proj"))
205
+ assert info == 2
154
206
 
155
207
 
156
208
  def test_grant_insertion(grant_db_fixture):
@@ -169,13 +221,13 @@ def test_grant_update(grant_db_fixture):
169
221
  users = db.get_vrauser(None, None, tables.get("user"))
170
222
  db.insert_grant("123abc", users[0][0], 100.0, tables.get("grant"))
171
223
  result = db.update_grant(
172
- "123abc", "9876xyz", users[0][0], 220.0, tables.get("grant")
224
+ 1, "9876xyz", users[0][0], 220.0, tables.get("grant")
173
225
  )
174
226
  info = db.get_grant(None, tables.get("grant"))
175
227
  assert len(info) == 1
176
228
  assert result
177
- assert info[0][1] == "9876xyz"
178
- assert info[0][3] == 220.0
229
+ assert info[0][2] == "9876xyz"
230
+ assert info[0][4] == 220.0
179
231
 
180
232
 
181
233
  def test_grant_remove(grant_db_fixture):
@@ -183,7 +235,7 @@ def test_grant_remove(grant_db_fixture):
183
235
  db.insert_vrauser("im530", "Ishan", tables.get("user"))
184
236
  users = db.get_vrauser(None, None, tables.get("user"))
185
237
  db.insert_grant("123abc", users[0][0], 100.0, tables.get("grant"))
186
- result = db.remove_grant("123abc", tables.get("grant"))
238
+ result = db.remove_grant(1, tables.get("grant"))
187
239
  info = db.get_grant(None, tables.get("grant"))
188
240
  assert len(info) == 0
189
241
  assert result
@@ -197,8 +249,8 @@ def test_grant_fetchall(grant_db_fixture):
197
249
  db.insert_grant("123xyz", users[0][0], 200.0, tables.get("grant"))
198
250
  info = db.get_grant(None, tables.get("grant"))
199
251
  assert len(info) == 2
200
- assert info[0][1] == "123abc"
201
- assert info[1][1] == "123xyz"
252
+ assert info[0][2] == "123abc"
253
+ assert info[1][2] == "123xyz"
202
254
 
203
255
 
204
256
  def test_grant_fetch_one(grant_db_fixture):
@@ -209,7 +261,27 @@ def test_grant_fetch_one(grant_db_fixture):
209
261
  db.insert_grant("123xyz", users[0][0], 200.0, tables.get("grant"))
210
262
  info = db.get_grant("123xyz", tables.get("grant"))
211
263
  assert len(info) == 1
212
- assert info[0][1] == "123xyz"
264
+ assert info[0][2] == "123xyz"
265
+
266
+
267
+ def test_grant_fetch_by_id(grant_db_fixture):
268
+ db = grant_db_fixture
269
+ db.insert_vrauser("im530", "Ishan", tables.get("user"))
270
+ users = db.get_vrauser(None, None, tables.get("user"))
271
+ db.insert_grant("123abc", users[0][0], 100.0, tables.get("grant"))
272
+ db.insert_grant("123xyz", users[0][0], 200.0, tables.get("grant"))
273
+ info = db.get_grant_by_id(2, tables.get("grant"))
274
+ assert info[2] == "123xyz"
275
+
276
+
277
+ def test_grant_primary_key(grant_db_fixture):
278
+ db = grant_db_fixture
279
+ db.insert_vrauser("im530", "Ishan", tables.get("user"))
280
+ users = db.get_vrauser(None, None, tables.get("user"))
281
+ db.insert_grant("123abc", users[0][0], 100.0, tables.get("grant"))
282
+ db.insert_grant("123xyz", users[0][0], 200.0, tables.get("grant"))
283
+ info = db.get_grant_primary_key("123xyz", None, tables.get("grant"))
284
+ assert info == 2
213
285
 
214
286
 
215
287
  def test_costing_insertion(costing_db_fixture):
@@ -249,12 +321,10 @@ def test_costing_update(costing_db_fixture):
249
321
  deploy[0][0], "Resource Expansion", proj[0][0], None, tables.get("costing")
250
322
  )
251
323
 
252
- info = db.get_costing(None, None, None, None, tables.get("costing"))
253
324
  result = db.update_costing(
325
+ 1,
254
326
  deploy[0][0],
255
327
  "Resource Expansion",
256
- None,
257
- proj[0][0],
258
328
  grant[0][0],
259
329
  None,
260
330
  tables.get("costing"),
@@ -281,9 +351,7 @@ def test_costing_remove(costing_db_fixture):
281
351
  deploy[0][0], "Resource Expansion", proj[0][0], None, tables.get("costing")
282
352
  )
283
353
 
284
- result = db.remove_costing(
285
- deploy[0][0], "Resource Expansion", proj[0][0], None, tables.get("costing")
286
- )
354
+ result = db.remove_costing(1, tables.get("costing"))
287
355
 
288
356
  info = db.get_costing(None, None, None, None, tables.get("costing"))
289
357
  assert len(info) == 0
@@ -337,3 +405,43 @@ def test_costing_fetch_one(costing_db_fixture):
337
405
  )
338
406
  assert len(info) == 1
339
407
  assert info[0][2] == "Duration Expansion"
408
+
409
+
410
+ def test_costing_fetch_by_id(costing_db_fixture):
411
+ db = costing_db_fixture
412
+ db.insert_vrauser("im530", "Ishan", "test_user")
413
+ users = db.get_vrauser(None, None, tables.get("user"))
414
+
415
+ db.insert_deployment_id("121212", tables.get("deploymentid"))
416
+ deploy = db.get_deployment_id(None, tables.get("deploymentid"))
417
+
418
+ db.insert_project("123abc", users[0][0], 100.0, tables.get("proj"))
419
+ proj = db.get_project(None, tables.get("proj"))
420
+
421
+ db.insert_costing(
422
+ deploy[0][0], "Duration Expansion", proj[0][0], None, tables.get("costing")
423
+ )
424
+
425
+ info = db.get_costing_by_id(1, tables.get("costing"))
426
+ assert info[1] == deploy[0][0]
427
+ assert info[2] == "Duration Expansion"
428
+ assert info[3] == proj[0][0]
429
+
430
+
431
+ def test_costing_fetch_primary_key(costing_db_fixture):
432
+ db = costing_db_fixture
433
+ db.insert_vrauser("im530", "Ishan", "test_user")
434
+ users = db.get_vrauser(None, None, tables.get("user"))
435
+
436
+ db.insert_deployment_id("121212", tables.get("deploymentid"))
437
+ deploy = db.get_deployment_id(None, tables.get("deploymentid"))
438
+
439
+ db.insert_project("123abc", users[0][0], 100.0, tables.get("proj"))
440
+ proj = db.get_project(None, tables.get("proj"))
441
+
442
+ db.insert_costing(
443
+ deploy[0][0], "Duration Expansion", proj[0][0], None, tables.get("costing")
444
+ )
445
+
446
+ info = db.get_costing_primary_key(deploy[0][0], "Duration Expansion", proj[0][0], None, tables.get("costing"))
447
+ assert info == 1
ucampostgresvro/utils.py CHANGED
@@ -151,6 +151,7 @@ def create_project_table(
151
151
  """
152
152
  design = f"CREATE TABLE {proj_tablename} (\
153
153
  id SERIAL PRIMARY KEY, \
154
+ date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, \
154
155
  project_number VARCHAR(255), \
155
156
  paid_by INTEGER REFERENCES {user_tablename}(id), \
156
157
  amount FLOAT NOT NULL \
@@ -173,6 +174,7 @@ def create_grant_table(
173
174
  """
174
175
  design = f"CREATE TABLE {grant_tablename} (\
175
176
  id SERIAL PRIMARY KEY,\
177
+ date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, \
176
178
  grant_number VARCHAR(255),\
177
179
  paid_by INTEGER REFERENCES {user_tablename}(id),\
178
180
  amount FLOAT NOT NULL\
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: ucampostgresvro
3
- Version: 0.1.2
3
+ Version: 0.2.1
4
4
  Summary: To connect with postgresql for the billing report
5
5
  Author: Ishan Mahajan
6
6
  Author-email: mahanishanmahajan@gmail.com
@@ -55,6 +55,8 @@ pre_setupconfig(db_params)
55
55
  - To perform CRUD operation
56
56
  ```
57
57
  from ucampostgresvro.DBA import DB
58
+ from datetime import datetime
59
+
58
60
  db_params = {
59
61
  "dbname": "vrapricing",
60
62
  "user": "postgres",
@@ -74,6 +76,15 @@ db.insert_vrauser("ll220", "Ling-Yan Lau")
74
76
  # read user
75
77
  print(db.get_vrauser())
76
78
 
79
+ # read user specific user by crsid
80
+ print(db.get_vrauser("ll220"))
81
+
82
+ # read user specific user by user id
83
+ print(db.get_vrauser_by_id(1))
84
+
85
+ # get the primary key of user using crsid
86
+ print(db.get_vrauser_primary_key("ll220"))
87
+
77
88
  # update user
78
89
  db.update_vrauser("ll220", "bda20", 'Ben Argyle')
79
90
 
@@ -83,9 +94,18 @@ db.remove_vrauser('bda20')
83
94
  # create vra deploymentid
84
95
  db.insert_deployment_id("1231ee112ad11212")
85
96
 
86
- # read vra deployment id
97
+ # read all the vra deployment ids
98
+ print(db.get_deployment_id())
99
+
100
+ # read specific specific deploymentid by deploymentid
87
101
  print(db.get_deployment_id("1231a"))
88
102
 
103
+ # read specific deploymentid by primary key
104
+ print(db.get_deployment_id_by_id(1))
105
+
106
+ # read primary key of specific deploymentid
107
+ print(db.get_deployment_id_primary_key("1231a"))
108
+
89
109
  # update vra deployment id
90
110
  db.update_deployment_id("1231ee112ad1", "1231a")
91
111
 
@@ -95,38 +115,77 @@ db.remove_deployment_id('1231a')
95
115
  # create project
96
116
  db.insert_project("0001",1,100.0)
97
117
 
98
- # read project
118
+ # read all the projects
99
119
  print(db.get_project())
100
120
 
101
- # update project
102
- db.update_project("0001", "0002", 4, 200)
121
+ # read specific project
122
+ print(db.get_project("0001"))
123
+
124
+ # read project from the ID
125
+ print(db.get_project_by_id(1))
126
+
127
+ # get the primary key of the project
128
+ print(db.get_project_primary_key("001"))
129
+
130
+ # get the primary key of the project if more than 1 entites using date of insertion.
131
+ print(db.get_project_primary_key("001", datetime(2025, 1, 22, 15, 55, 25, 95698)))
132
+
133
+ # update project with new information 1 is the primary key
134
+ db.update_project(1, "0002", 4, 200)
103
135
 
104
- # delete project
105
- # db.remove_project("0002")
136
+ # delete project using primary key of project
137
+ # db.remove_project(1)
106
138
 
107
139
  # create grant
108
140
  db.insert_grant("0001",1,100.0)
109
141
 
110
- # read grant
142
+ # read all the grants
111
143
  print(db.get_grant())
112
144
 
113
- # update grant
114
- db.update_grant("0001", "0002", 4, 200)
145
+ # read specific grant
146
+ print(db.get_grant("0001"))
115
147
 
116
- # delete grant
117
- db.remove_grant("0002")
148
+ # read grant from the ID
149
+ print(db.get_grant_by_id(1))
150
+
151
+ # get the primary key of the grant
152
+ print(db.get_grant_primary_key("001"))
153
+
154
+ # get the primary key of the grant if more than 1 entites using date of insertion.
155
+ print(db.get_grant_primary_key("001", datetime(2025, 1, 22, 15, 55, 25, 95698)))
156
+
157
+ # update grant with new information 1 is the primary key of grant
158
+ db.update_grant(1, "2002", 4, 200)
159
+
160
+ # delete grant 1 is the primary key of the grant
161
+ db.remove_grant(1)
118
162
 
119
163
  # create costing
120
164
  db.insert_costing(2, "Initial Resource", project_id=4, grant_id=None)
121
165
 
122
- # read costing
166
+ # read all the costing
123
167
  print(db.get_costing())
124
168
 
125
- # update costing
126
- db.update_costing(2, "Duration Expansion", old_grant_id=4, old_project_id=None, grant_id=4, project_id=None)
169
+ # read specific costing using primary key of the costing
170
+ print(db.get_costing_by_id(1))
171
+
172
+ # read specific costing for the project
173
+ print(db.get_costing(2, "Initial Resource", 2))
127
174
 
128
- # delete costing
129
- db.remove_costing(2, "Duration Expansion", 4, None)
175
+ # read specific costing for the grant
176
+ print(db.get_costing(2, "Initial Resource", None, 2))
177
+
178
+ # get primary key for the specific costing for the project
179
+ print(db.get_costing_primary_key(2, "Initial Resource", 2))
180
+
181
+ # get primary key for the specific costing for the grant
182
+ print(db.get_costing_primary_key(2, "Initial Resource", None, 2))
183
+
184
+ # update costing where 3 is the primary key of the costing.
185
+ db.update_costing(3, 2, "Duration Expansion", new_grant_id=None, new_project_id=2)
186
+
187
+ # delete costing where 3 is the primary key
188
+ db.remove_costing(3)
130
189
 
131
190
  # to close db connection
132
191
  db.closedb()
@@ -173,39 +232,40 @@ Referenced by:
173
232
 
174
233
  ## - project table
175
234
  ```
176
- vrapricing=# \d projects;
177
- Table "public.projects"
178
- Column | Type | Collation | Nullable | Default
179
- ----------------+------------------------+-----------+----------+--------------------------------------
180
- id | integer | | not null | nextval('projects_id_seq'::regclass)
181
- project_number | character varying(255) | | |
182
- paid_by | integer | | |
183
- amount | double precision | | not null |
235
+ vrapricing=# \d projects
236
+ Table "public.projects"
237
+ Column | Type | Collation | Nullable | Default
238
+ ----------------+-----------------------------+-----------+----------+--------------------------------------
239
+ id | integer | | not null | nextval('projects_id_seq'::regclass)
240
+ date | timestamp without time zone | | | CURRENT_TIMESTAMP
241
+ project_number | character varying(255) | | |
242
+ paid_by | integer | | |
243
+ amount | double precision | | not null |
184
244
  Indexes:
185
245
  "projects_pkey" PRIMARY KEY, btree (id)
186
246
  Foreign-key constraints:
187
247
  "projects_paid_by_fkey" FOREIGN KEY (paid_by) REFERENCES vrauser(id)
188
248
  Referenced by:
189
249
  TABLE "costing" CONSTRAINT "costing_project_id_fkey" FOREIGN KEY (project_id) REFERENCES projects(id)
190
-
191
250
  ```
192
251
 
193
252
  ## - grants table
194
253
  ```
195
- vrapricing=# \d grant;
196
- Table "public.grant"
197
- Column | Type | Collation | Nullable | Default
198
- ----------------+------------------------+-----------+----------+--------------------------------------
199
- id | integer | | not null | nextval('grant_id_seq'::regclass)
200
- voucher_number | character varying(255) | | |
201
- paid_by | integer | | |
202
- amount | double precision | | not null |
254
+ vrapricing=# \d grants
255
+ Table "public.grants"
256
+ Column | Type | Collation | Nullable | Default
257
+ --------------+-----------------------------+-----------+----------+------------------------------------
258
+ id | integer | | not null | nextval('grants_id_seq'::regclass)
259
+ date | timestamp without time zone | | | CURRENT_TIMESTAMP
260
+ grant_number | character varying(255) | | |
261
+ paid_by | integer | | |
262
+ amount | double precision | | not null |
203
263
  Indexes:
204
- "grant_pkey" PRIMARY KEY, btree (id)
264
+ "grants_pkey" PRIMARY KEY, btree (id)
205
265
  Foreign-key constraints:
206
- "grant_paid_by_fkey" FOREIGN KEY (paid_by) REFERENCES vrauser(id)
266
+ "grants_paid_by_fkey" FOREIGN KEY (paid_by) REFERENCES vrauser(id)
207
267
  Referenced by:
208
- TABLE "costing" CONSTRAINT "costing_voucher_id_fkey" FOREIGN KEY (voucher_id) REFERENCES grant(id)
268
+ TABLE "costing" CONSTRAINT "costing_grant_id_fkey" FOREIGN KEY (grant_id) REFERENCES grants(id)
209
269
  ```
210
270
 
211
271
  ## - Costing table
@@ -0,0 +1,16 @@
1
+ ucampostgresvro/DBA.py,sha256=x795bE2kUOiDc1274bFXO1dMlQlvGQXZayirE0TGlZM,38597
2
+ ucampostgresvro/__init__.py,sha256=w9Iw7QVvd8lme2wKwEbCo5IgetVjSfFBOOYAcA_Q0Ns,18
3
+ ucampostgresvro/__main__.py,sha256=KzZTQ308dHN0OuvxObUhCdGJz2sbb8iFr-wOP6_iSMg,4128
4
+ ucampostgresvro/ca.crt,sha256=pVDr3AsvwCqJ36JTifsAzIiS2ve_fWC1CBfVI0cnVmY,1135
5
+ ucampostgresvro/exceptions.py,sha256=XVi8Sk_gg3VE4ryTtiYOnGbmCPIsfFt2AE5sOoqQDuI,39
6
+ ucampostgresvro/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ ucampostgresvro/tests/conftest.py,sha256=t89U_SOcWf2q0C_m4Vn89LSLwxnQC-_rUAvt6yNeOWA,1803
8
+ ucampostgresvro/tests/dbconnect.py,sha256=pKU95buCUAUw0plBcaFqhCn7zPjW_PQreONasHlEh_Q,241
9
+ ucampostgresvro/tests/test_DB.py,sha256=lye6NLUS2k7W7Kr083fQ5HDUD5hMMUqvIXL2xbNoRUk,16338
10
+ ucampostgresvro/tests/utils.py,sha256=lpcvf6HPOOtxAwSwvoAUhil1zQ6Qfr0ZILa0qDVdES0,3722
11
+ ucampostgresvro/tools.py,sha256=Y8MUK1lIG10A-724yrhve8LfjQUmFwpqi19UIO5DeuI,153
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,,
@@ -1,16 +0,0 @@
1
- ucampostgresvro/DBA.py,sha256=LGj2JpP2B-6z7CFV-zloLNmW8dPcIyuItVRi5x0KQT0,30876
2
- ucampostgresvro/__init__.py,sha256=3ITyQfKn-h4AMdaHk5rHJaliZbCnbLZ7O3QQnAJH8yI,18
3
- ucampostgresvro/__main__.py,sha256=oEX2F0_bl2Xrq6_l9YZb1ZBIhxRwzuSPpauqjCm0YjE,2780
4
- ucampostgresvro/ca.crt,sha256=pVDr3AsvwCqJ36JTifsAzIiS2ve_fWC1CBfVI0cnVmY,1135
5
- ucampostgresvro/exceptions.py,sha256=XVi8Sk_gg3VE4ryTtiYOnGbmCPIsfFt2AE5sOoqQDuI,39
6
- ucampostgresvro/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- ucampostgresvro/tests/conftest.py,sha256=t89U_SOcWf2q0C_m4Vn89LSLwxnQC-_rUAvt6yNeOWA,1803
8
- ucampostgresvro/tests/dbconnect.py,sha256=T2rVoUmG6mHwS-i4h8R4O4GuEhuucCd3zyrFUMMhkE4,240
9
- ucampostgresvro/tests/test_DB.py,sha256=SLi5C0NO0dIeIQOfywkAPWKznfANopVEnHOxCD-EZpU,12134
10
- ucampostgresvro/tests/utils.py,sha256=lpcvf6HPOOtxAwSwvoAUhil1zQ6Qfr0ZILa0qDVdES0,3722
11
- ucampostgresvro/tools.py,sha256=Y8MUK1lIG10A-724yrhve8LfjQUmFwpqi19UIO5DeuI,153
12
- ucampostgresvro/utils.py,sha256=ZHS9D3Eplyk3Ck-AoVG_2YgVJJNmuO6J-FaZGsJKGs4,8439
13
- ucampostgresvro-0.1.2.dist-info/LICENSE,sha256=CVTj8C-BHEJjzYlYtHnfykxKkfmk-ImXOs5rcMgXebY,1094
14
- ucampostgresvro-0.1.2.dist-info/METADATA,sha256=ICcEjopmJAXYGhqzbGO-H3JSFO2dBV33vuV8qslIEAw,7649
15
- ucampostgresvro-0.1.2.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
16
- ucampostgresvro-0.1.2.dist-info/RECORD,,