commons-metrics 0.0.5__tar.gz → 0.0.6__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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: commons_metrics
3
- Version: 0.0.5
3
+ Version: 0.0.6
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,6 @@
1
+ from .util import Util
2
+ from .database import DatabaseConnection
3
+ from .repositories import ComponentRepository
4
+
5
+ __all__ = ['Util', 'DatabaseConnection', 'ComponentRepository']
6
+ __version__ = '0.0.6'
@@ -0,0 +1,43 @@
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
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: commons_metrics
3
- Version: 0.0.5
3
+ Version: 0.0.6
4
4
  Summary: A simple library for basic statistical calculations
5
5
  Author: Bancolombia
6
6
  Author-email: omar.david.pino@email.com
@@ -3,6 +3,7 @@ README.md
3
3
  setup.py
4
4
  commons_metrics/__init__.py
5
5
  commons_metrics/database.py
6
+ commons_metrics/repositories.py
6
7
  commons_metrics/util.py
7
8
  commons_metrics.egg-info/PKG-INFO
8
9
  commons_metrics.egg-info/SOURCES.txt
@@ -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',
5
+ version='0.0.6',
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,5 +0,0 @@
1
- from .util import Util
2
- from .database import DatabaseConnection
3
-
4
- __all__ = ['Util', 'DatabaseConnection']
5
- __version__ = '0.0.5'
File without changes