Common Mamon11 tools and utilities
Project description
Mamon Utilities
A set of tools and utilities for Python Development
Installation
pip install mamon-utils
Usage
To use any of these modules, just import from mamonutils
.
Database
This module makes it easy to connect to our PostgreSQL databases. To use it, you have to add a .env
file in the root of your project specifying the following environment variables:
DB_HOST=
DB_PORT=
DB_USER=
DB_PASSWORD=
Example Usage
from mamonutils import Database, dotenv
# Load environment variables
dotenv()
# Connect to clients database
db = Database('clients')
cursor = db.cursor
cursor.execute('SELECT * from clients')
result = cursor.fetchall()
print(result)
# Disconnect
db.disconnect()
get_dimensions
A utility that allows you to retrieve the dimensions (width and height) of an image from a given URL. The utility uses the requests module to fetch the image data and the PIL (Python Imaging Library) module to extract the image metadata. The utility is designed to be flexible, allowing users to handle exceptions and errors according to their specific needs.
Example Usage
The utility takes a URL string as input and returns a dictionary containing the image's width and height.
from mamonutils import get_dimensions
try:
image_url = "https://example.com/image.jpg"
dimensions = get_dimensions(image_url)
print("Image Dimensions:")
print(f"Width: {dimensions['width']}")
print(f"Height: {dimensions['height']}")
except ValueError as e:
print(f"Error: {str(e)}")
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for mamon_utils-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 927d4936a185a51787a61a696e09bb9fdb05fadba0e18be3e5b5ea78170f203c |
|
MD5 | dabe86b8c1dcac119bc3e713084f3ed6 |
|
BLAKE2b-256 | 9510949ef5080f3bbe3ce966b3225ec3eeb59554e7198d1392342f02f19b95b5 |