ucampostgresvro 0.1.1__tar.gz → 0.1.2__tar.gz

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,7 +1,7 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: ucampostgresvro
3
- Version: 0.1.1
4
- Summary:
3
+ Version: 0.1.2
4
+ Summary: To connect with postgresql for the billing report
5
5
  Author: Ishan Mahajan
6
6
  Author-email: mahanishanmahajan@gmail.com
7
7
  Requires-Python: >=3.10
@@ -38,7 +38,7 @@ Description-Content-Type: text/markdown
38
38
 
39
39
  - To setup database
40
40
  ```
41
- from ucampostgresvro import pre_setupconfig
41
+ from ucampostgresvro.utils import pre_setupconfig
42
42
  from ucampostgresvro.DBA import DB
43
43
  db_params = {
44
44
  "dbname": "vrapricing",
@@ -23,7 +23,7 @@
23
23
 
24
24
  - To setup database
25
25
  ```
26
- from ucampostgresvro import pre_setupconfig
26
+ from ucampostgresvro.utils import pre_setupconfig
27
27
  from ucampostgresvro.DBA import DB
28
28
  db_params = {
29
29
  "dbname": "vrapricing",
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "ucampostgresvro"
3
- version = "0.1.1"
4
- description = ""
3
+ version = "0.1.2"
4
+ description = "To connect with postgresql for the billing report"
5
5
  authors = [
6
6
  {name = "Ishan Mahajan",email = "mahanishanmahajan@gmail.com"}
7
7
  ]
@@ -0,0 +1 @@
1
+ VERSION = "0.1.2"
@@ -1,12 +1,10 @@
1
1
  import logging
2
2
  import sys
3
- from typing import Dict
4
3
 
5
4
  from ucampostgresvro import VERSION, utils
6
5
  from ucampostgresvro.DBA import DB
7
6
  from ucampostgresvro.exceptions import DbException
8
7
  from ucampostgresvro.secrets import password
9
- from ucampostgresvro.tools import DEFAULT_TABLES
10
8
 
11
9
 
12
10
  def setloggerdetail():
@@ -21,52 +19,6 @@ def setloggerdetail():
21
19
  return LOG
22
20
 
23
21
 
24
- def pre_setupconfig(db_params: Dict[str, str]) -> bool:
25
- """Create the Database
26
-
27
- Args:
28
- db_params (Dict[str, str]): provide parameters for DB connection.
29
-
30
- Returns:
31
- bool: True if creation of database is suceess else False
32
- """
33
- result = []
34
- if not utils.check_table_exists(DEFAULT_TABLES.get("user"), db_params):
35
- result.append(utils.create_user_table(DEFAULT_TABLES.get("user"), db_params))
36
-
37
- if not utils.check_table_exists(DEFAULT_TABLES.get("deploymentid"), db_params):
38
- result.append(
39
- utils.create_deployment_table(DEFAULT_TABLES.get("deploymentid"), db_params)
40
- )
41
-
42
- if not utils.check_table_exists(DEFAULT_TABLES.get("proj"), db_params):
43
- result.append(
44
- utils.create_project_table(
45
- DEFAULT_TABLES.get("proj"), DEFAULT_TABLES.get("user"), db_params
46
- )
47
- )
48
-
49
- if not utils.check_table_exists(DEFAULT_TABLES.get("grant"), db_params):
50
- result.append(
51
- utils.create_grant_table(
52
- DEFAULT_TABLES.get("grant"), DEFAULT_TABLES.get("user"), db_params
53
- )
54
- )
55
-
56
- if not utils.check_table_exists(DEFAULT_TABLES.get("costing"), db_params):
57
- result.append(
58
- utils.create_costing_table(
59
- DEFAULT_TABLES.get("costing"),
60
- DEFAULT_TABLES.get("deploymentid"),
61
- DEFAULT_TABLES.get("proj"),
62
- DEFAULT_TABLES.get("grant"),
63
- db_params,
64
- )
65
- )
66
-
67
- return False not in result
68
-
69
-
70
22
  def main():
71
23
  LOG = setloggerdetail()
72
24
  LOG.info(f"VERSION : {VERSION}")
@@ -81,7 +33,7 @@ def main():
81
33
  }
82
34
  db = DB(db_params)
83
35
 
84
- if not pre_setupconfig(db_params):
36
+ if not utils.pre_setupconfig(db_params):
85
37
  raise DbException("ERROR: Tables are not created successfully")
86
38
 
87
39
  # db.insert_vrauser("ll220", "len")
@@ -3,10 +3,52 @@ from typing import Callable, Dict
3
3
 
4
4
  from ucampostgresvro.DBA import DB
5
5
  from ucampostgresvro.exceptions import DbException
6
+ from ucampostgresvro.tools import DEFAULT_TABLES
6
7
 
7
8
  LOG = logging.getLogger(__name__)
8
9
 
9
10
 
11
+ def pre_setupconfig(db_params: Dict[str, str]) -> bool:
12
+ """Create the Database
13
+
14
+ Args:
15
+ db_params (Dict[str, str]): provide parameters for DB connection.
16
+
17
+ Returns:
18
+ bool: True if creation of database is suceess else False
19
+ """
20
+ result = []
21
+ if not check_table_exists(DEFAULT_TABLES.get("user"), db_params):
22
+ result.append(create_user_table(DEFAULT_TABLES.get("user"), db_params))
23
+ if not check_table_exists(DEFAULT_TABLES.get("deploymentid"), db_params):
24
+ result.append(
25
+ create_deployment_table(DEFAULT_TABLES.get("deploymentid"), db_params)
26
+ )
27
+ if not check_table_exists(DEFAULT_TABLES.get("proj"), db_params):
28
+ result.append(
29
+ create_project_table(
30
+ DEFAULT_TABLES.get("proj"), DEFAULT_TABLES.get("user"), db_params
31
+ )
32
+ )
33
+ if not check_table_exists(DEFAULT_TABLES.get("grant"), db_params):
34
+ result.append(
35
+ create_grant_table(
36
+ DEFAULT_TABLES.get("grant"), DEFAULT_TABLES.get("user"), db_params
37
+ )
38
+ )
39
+ if not check_table_exists(DEFAULT_TABLES.get("costing"), db_params):
40
+ result.append(
41
+ create_costing_table(
42
+ DEFAULT_TABLES.get("costing"),
43
+ DEFAULT_TABLES.get("deploymentid"),
44
+ DEFAULT_TABLES.get("proj"),
45
+ DEFAULT_TABLES.get("grant"),
46
+ db_params,
47
+ )
48
+ )
49
+ return False not in result
50
+
51
+
10
52
  def create_table(tablename: str, db_params: Dict[str, str], design: str) -> bool:
11
53
  """Creation of table with provided design
12
54
 
@@ -1 +0,0 @@
1
- VERSION = "0.1.1"
File without changes