commons-metrics 0.0.3__tar.gz → 0.0.5__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.3 → commons_metrics-0.0.5}/PKG-INFO +1 -1
- {commons_metrics-0.0.3 → commons_metrics-0.0.5}/README.md +8 -1
- commons_metrics-0.0.5/commons_metrics/__init__.py +5 -0
- commons_metrics-0.0.5/commons_metrics/database.py +39 -0
- {commons_metrics-0.0.3 → commons_metrics-0.0.5}/commons_metrics/util.py +9 -8
- {commons_metrics-0.0.3 → commons_metrics-0.0.5}/commons_metrics.egg-info/PKG-INFO +1 -1
- {commons_metrics-0.0.3 → commons_metrics-0.0.5}/commons_metrics.egg-info/SOURCES.txt +1 -0
- {commons_metrics-0.0.3 → commons_metrics-0.0.5}/setup.py +1 -1
- commons_metrics-0.0.3/commons_metrics/__init__.py +0 -4
- {commons_metrics-0.0.3 → commons_metrics-0.0.5}/LICENSE +0 -0
- {commons_metrics-0.0.3 → commons_metrics-0.0.5}/commons_metrics.egg-info/dependency_links.txt +0 -0
- {commons_metrics-0.0.3 → commons_metrics-0.0.5}/commons_metrics.egg-info/requires.txt +0 -0
- {commons_metrics-0.0.3 → commons_metrics-0.0.5}/commons_metrics.egg-info/top_level.txt +0 -0
- {commons_metrics-0.0.3 → commons_metrics-0.0.5}/setup.cfg +0 -0
|
@@ -10,9 +10,16 @@ A simple Python library for basic statistical calculations.
|
|
|
10
10
|
- Calculate standard deviation
|
|
11
11
|
|
|
12
12
|
## Dev
|
|
13
|
-
|
|
13
|
+
python3 setup.py sdist bdist_wheel
|
|
14
14
|
twine upload dist/*
|
|
15
15
|
input token
|
|
16
|
+
git ignore buill,commons_metrics.egg-info, dist
|
|
17
|
+
|
|
18
|
+
## Build Dependencies
|
|
19
|
+
pip install twine
|
|
20
|
+
|
|
21
|
+
pip install commons_metrics==0.0.4
|
|
22
|
+
|
|
16
23
|
|
|
17
24
|
## Installation
|
|
18
25
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import psycopg2
|
|
2
|
+
|
|
3
|
+
class DatabaseConnection:
|
|
4
|
+
"""
|
|
5
|
+
Class to handle PostgreSQL database connections
|
|
6
|
+
using AWS Secrets Manager credentials
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
def __init__(self):
|
|
10
|
+
self.connection = None
|
|
11
|
+
|
|
12
|
+
def connect(self, credentials):
|
|
13
|
+
"""Establishes database connection using credentials"""
|
|
14
|
+
try:
|
|
15
|
+
self.connection = psycopg2.connect(
|
|
16
|
+
host=credentials['host'],
|
|
17
|
+
port=credentials['port'],
|
|
18
|
+
database=credentials['dbname'],
|
|
19
|
+
user=credentials['username'],
|
|
20
|
+
password=credentials['password'],
|
|
21
|
+
connect_timeout=30
|
|
22
|
+
)
|
|
23
|
+
except Exception as e:
|
|
24
|
+
raise Exception(f"Database connection error: {str(e)}")
|
|
25
|
+
|
|
26
|
+
def close(self):
|
|
27
|
+
"""Closes the database connection"""
|
|
28
|
+
if self.connection and not self.connection.closed:
|
|
29
|
+
self.connection.close()
|
|
30
|
+
|
|
31
|
+
def commit_transaction(self):
|
|
32
|
+
"""Commits pending transactions"""
|
|
33
|
+
if self.connection and not self.connection.closed:
|
|
34
|
+
self.connection.commit()
|
|
35
|
+
|
|
36
|
+
def rollback_transaction(self):
|
|
37
|
+
"""Rolls back pending transactions in case of error"""
|
|
38
|
+
if self.connection and not self.connection.closed:
|
|
39
|
+
self.connection.rollback()
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import boto3
|
|
2
2
|
import json
|
|
3
|
+
|
|
3
4
|
class Util:
|
|
5
|
+
"""Utility class for common operations"""
|
|
6
|
+
|
|
4
7
|
@staticmethod
|
|
5
|
-
def get_secret_aws(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
def get_secret_aws(secret_name: str, logger, region_name: str):
|
|
9
|
+
"""
|
|
10
|
+
Retrieves AWS Secrets Manager secret and returns database credentials
|
|
11
|
+
"""
|
|
9
12
|
try:
|
|
10
13
|
session = boto3.session.Session()
|
|
11
14
|
client = session.client(
|
|
@@ -31,7 +34,5 @@ class Util:
|
|
|
31
34
|
msg = f"Error getting the secret '{secret_name}': {str(e)}"
|
|
32
35
|
logger.error(msg)
|
|
33
36
|
raise Exception(msg)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def show(env: str, logger):
|
|
37
|
-
print("Hola mundo")
|
|
37
|
+
|
|
38
|
+
|
|
@@ -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.5',
|
|
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',
|
|
File without changes
|
{commons_metrics-0.0.3 → commons_metrics-0.0.5}/commons_metrics.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|