commons-metrics 0.0.6__py3-none-any.whl → 0.0.7__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.
@@ -3,4 +3,4 @@ from .database import DatabaseConnection
3
3
  from .repositories import ComponentRepository
4
4
 
5
5
  __all__ = ['Util', 'DatabaseConnection', 'ComponentRepository']
6
- __version__ = '0.0.6'
6
+ __version__ = '0.0.7'
@@ -9,14 +9,14 @@ class ComponentRepository:
9
9
  """
10
10
  self.db = db_connection
11
11
 
12
- def save_component(self, technical_name, id_type, status=1):
12
+ def save_component(self, technical_name, id_type, status):
13
13
  """
14
14
  Inserts a new component into schmesys.component table
15
15
 
16
16
  Args:
17
17
  technical_name (str): Technical name of the component
18
18
  id_type (int): Component type ID
19
- status (int): Component status (default: 1)
19
+ status (int): Component status
20
20
  """
21
21
  cursor = None
22
22
  try:
@@ -41,3 +41,42 @@ class ComponentRepository:
41
41
  if cursor:
42
42
  cursor.close()
43
43
 
44
+ def query_components_by_type(self, id_type: int) -> list:
45
+ """
46
+ Consulta componentes de un tipo específico en la base de datos
47
+
48
+ Args:
49
+ id_type (int): ID del tipo de componente a consultar
50
+ """
51
+ cursor = None
52
+ try:
53
+ cursor = self.db.connection.cursor()
54
+
55
+ query = """
56
+ SELECT id, technical_name, id_type, status
57
+ FROM schmesys.component
58
+ WHERE id_type = %s
59
+ ORDER BY technical_name
60
+ """
61
+
62
+ cursor.execute(query, (id_type,))
63
+ results = cursor.fetchall()
64
+
65
+ components = []
66
+ for row in results:
67
+ component = {
68
+ 'id': row[0],
69
+ 'technical_name': row[1],
70
+ 'id_type': row[2],
71
+ 'status': row[3]
72
+ }
73
+ components.append(component)
74
+
75
+ return components
76
+
77
+ except Exception as e:
78
+ raise Exception(f"Error querying components by type {id_type}: {str(e)}")
79
+ finally:
80
+ if cursor:
81
+ cursor.close()
82
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: commons_metrics
3
- Version: 0.0.6
3
+ Version: 0.0.7
4
4
  Summary: A simple library for basic statistical calculations
5
5
  Author: Bancolombia
6
6
  Author-email: omar.david.pino@email.com
@@ -0,0 +1,9 @@
1
+ commons_metrics/__init__.py,sha256=elSwj8Oszh-JG6ZSZD0_GLgw0DJRjjBpsFUgsJNcLIM,196
2
+ commons_metrics/database.py,sha256=570TtLZ9psNzvIp75UFLYph34cKVEz6eGJgxXyRyjW4,1285
3
+ commons_metrics/repositories.py,sha256=GtAsVMbcfyftKQlMhyxLqxwVi3B7EwbopmHafZgxxJE,2559
4
+ commons_metrics/util.py,sha256=98zuynalXumQRh-BB0Bcjyoh6vS2BTOUM8tVgr7iS9Q,1225
5
+ commons_metrics-0.0.7.dist-info/licenses/LICENSE,sha256=jsHZ2Sh1wCL74HC25pDDGXCyQ0xgsTAy62FvEnehKIg,1067
6
+ commons_metrics-0.0.7.dist-info/METADATA,sha256=Vq78qEafWd7_XZUvuJEPV5OEq-e4dSrTPCu4u8nguMo,401
7
+ commons_metrics-0.0.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
+ commons_metrics-0.0.7.dist-info/top_level.txt,sha256=lheUN-3OKdU3A8Tg8Y-1IEB_9i_vVRA0g_FOiUsTQz8,16
9
+ commons_metrics-0.0.7.dist-info/RECORD,,
@@ -1,45 +0,0 @@
1
- import psycopg2
2
-
3
- class DataBase:
4
- def __init__(self, db_name):
5
- self.connection = None
6
-
7
- def connect(self, host, port, dbname, user, password):
8
- try:
9
- self.connection = psycopg2.connect(
10
- host=host,
11
- port=port,
12
- database=dbname,
13
- user=user,
14
- password=password,
15
- connect_timeout=30
16
- )
17
-
18
- except Exception as e:
19
- if self.connection:
20
- self.connection.rollback()
21
- msg = f"Database connection error: {str(e)}"
22
- raise Exception(msg)
23
-
24
- def disconnect(self):
25
- if self.connectWWWion:
26
- self.connection.close()
27
-
28
- def save_component(technical_name, id_type):
29
- try:
30
- cursor = connection.cursor()
31
- params_insert = (
32
- technical_name,
33
- id_type
34
- )
35
-
36
- #cursor.execute("select id_component into v_id_component from schmesys.component where technical_name = v_component_name;", params)
37
- cursor.execute("INSERT INTO schmesys.component(technical_name,id_type) values (%s, %d);", params_insert)
38
- except Exception as e:
39
- if self.connection:
40
- self.connection.rollback()
41
- msg = f"Database connection error: {str(e)}"
42
- raise Exception(msg)
43
- finally:
44
- if cursor:
45
- cursor.close()
@@ -1,10 +0,0 @@
1
- commons_metrics/__init__.py,sha256=W2Qz4cA0bOvTGIlf3R0eNMg6DJ8XhgK4eChf8gOyw8k,196
2
- commons_metrics/data_base.py,sha256=7I9ywLqQMtTlK1uuubM8WrffwDsL9uyP3sygqanUQvQ,1439
3
- commons_metrics/database.py,sha256=570TtLZ9psNzvIp75UFLYph34cKVEz6eGJgxXyRyjW4,1285
4
- commons_metrics/repositories.py,sha256=JruFtcT3IOTOKn3euM67c0SZtJKmYVc07gN5dMAFSmw,1365
5
- commons_metrics/util.py,sha256=98zuynalXumQRh-BB0Bcjyoh6vS2BTOUM8tVgr7iS9Q,1225
6
- commons_metrics-0.0.6.dist-info/licenses/LICENSE,sha256=jsHZ2Sh1wCL74HC25pDDGXCyQ0xgsTAy62FvEnehKIg,1067
7
- commons_metrics-0.0.6.dist-info/METADATA,sha256=-FNZi97I757Id2ukBPtK_PvJvq1SGtTvFdihDL75GSA,401
8
- commons_metrics-0.0.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
- commons_metrics-0.0.6.dist-info/top_level.txt,sha256=lheUN-3OKdU3A8Tg8Y-1IEB_9i_vVRA0g_FOiUsTQz8,16
10
- commons_metrics-0.0.6.dist-info/RECORD,,