commons-metrics 0.0.6__tar.gz → 0.0.7__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.
- {commons_metrics-0.0.6 → commons_metrics-0.0.7}/PKG-INFO +1 -1
- {commons_metrics-0.0.6 → commons_metrics-0.0.7}/commons_metrics/__init__.py +1 -1
- commons_metrics-0.0.7/commons_metrics/repositories.py +82 -0
- {commons_metrics-0.0.6 → commons_metrics-0.0.7}/commons_metrics.egg-info/PKG-INFO +1 -1
- {commons_metrics-0.0.6 → commons_metrics-0.0.7}/setup.py +1 -1
- commons_metrics-0.0.6/commons_metrics/repositories.py +0 -43
- {commons_metrics-0.0.6 → commons_metrics-0.0.7}/LICENSE +0 -0
- {commons_metrics-0.0.6 → commons_metrics-0.0.7}/README.md +0 -0
- {commons_metrics-0.0.6 → commons_metrics-0.0.7}/commons_metrics/database.py +0 -0
- {commons_metrics-0.0.6 → commons_metrics-0.0.7}/commons_metrics/util.py +0 -0
- {commons_metrics-0.0.6 → commons_metrics-0.0.7}/commons_metrics.egg-info/SOURCES.txt +0 -0
- {commons_metrics-0.0.6 → commons_metrics-0.0.7}/commons_metrics.egg-info/dependency_links.txt +0 -0
- {commons_metrics-0.0.6 → commons_metrics-0.0.7}/commons_metrics.egg-info/requires.txt +0 -0
- {commons_metrics-0.0.6 → commons_metrics-0.0.7}/commons_metrics.egg-info/top_level.txt +0 -0
- {commons_metrics-0.0.6 → commons_metrics-0.0.7}/setup.cfg +0 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
class ComponentRepository:
|
|
2
|
+
"""
|
|
3
|
+
Repository class for component-specific database operations
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
def __init__(self, db_connection):
|
|
7
|
+
"""
|
|
8
|
+
Initialize repository with database connection
|
|
9
|
+
"""
|
|
10
|
+
self.db = db_connection
|
|
11
|
+
|
|
12
|
+
def save_component(self, technical_name, id_type, status):
|
|
13
|
+
"""
|
|
14
|
+
Inserts a new component into schmesys.component table
|
|
15
|
+
|
|
16
|
+
Args:
|
|
17
|
+
technical_name (str): Technical name of the component
|
|
18
|
+
id_type (int): Component type ID
|
|
19
|
+
status (int): Component status
|
|
20
|
+
"""
|
|
21
|
+
cursor = None
|
|
22
|
+
try:
|
|
23
|
+
cursor = self.db.connection.cursor()
|
|
24
|
+
|
|
25
|
+
insert_query = """
|
|
26
|
+
INSERT INTO schmesys.component(technical_name, id_type, status)
|
|
27
|
+
VALUES (%s, %s, %s)
|
|
28
|
+
RETURNING id;
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
cursor.execute(insert_query, (technical_name, id_type, status))
|
|
32
|
+
component_id = cursor.fetchone()[0]
|
|
33
|
+
self.db.commit_transaction()
|
|
34
|
+
|
|
35
|
+
return component_id
|
|
36
|
+
|
|
37
|
+
except Exception as e:
|
|
38
|
+
self.db.rollback_transaction()
|
|
39
|
+
raise Exception(f"Error saving component '{technical_name}': {str(e)}")
|
|
40
|
+
finally:
|
|
41
|
+
if cursor:
|
|
42
|
+
cursor.close()
|
|
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
|
+
|
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name='commons_metrics',
|
|
5
|
-
version='0.0.
|
|
5
|
+
version='0.0.7',
|
|
6
6
|
description='A simple library for basic statistical calculations',
|
|
7
7
|
#long_description=open('USAGE.md').read(),
|
|
8
8
|
#long_description_content_type='text/markdown',
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
class ComponentRepository:
|
|
2
|
-
"""
|
|
3
|
-
Repository class for component-specific database operations
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
def __init__(self, db_connection):
|
|
7
|
-
"""
|
|
8
|
-
Initialize repository with database connection
|
|
9
|
-
"""
|
|
10
|
-
self.db = db_connection
|
|
11
|
-
|
|
12
|
-
def save_component(self, technical_name, id_type, status=1):
|
|
13
|
-
"""
|
|
14
|
-
Inserts a new component into schmesys.component table
|
|
15
|
-
|
|
16
|
-
Args:
|
|
17
|
-
technical_name (str): Technical name of the component
|
|
18
|
-
id_type (int): Component type ID
|
|
19
|
-
status (int): Component status (default: 1)
|
|
20
|
-
"""
|
|
21
|
-
cursor = None
|
|
22
|
-
try:
|
|
23
|
-
cursor = self.db.connection.cursor()
|
|
24
|
-
|
|
25
|
-
insert_query = """
|
|
26
|
-
INSERT INTO schmesys.component(technical_name, id_type, status)
|
|
27
|
-
VALUES (%s, %s, %s)
|
|
28
|
-
RETURNING id;
|
|
29
|
-
"""
|
|
30
|
-
|
|
31
|
-
cursor.execute(insert_query, (technical_name, id_type, status))
|
|
32
|
-
component_id = cursor.fetchone()[0]
|
|
33
|
-
self.db.commit_transaction()
|
|
34
|
-
|
|
35
|
-
return component_id
|
|
36
|
-
|
|
37
|
-
except Exception as e:
|
|
38
|
-
self.db.rollback_transaction()
|
|
39
|
-
raise Exception(f"Error saving component '{technical_name}': {str(e)}")
|
|
40
|
-
finally:
|
|
41
|
-
if cursor:
|
|
42
|
-
cursor.close()
|
|
43
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{commons_metrics-0.0.6 → commons_metrics-0.0.7}/commons_metrics.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|