Skip to main content

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

mamon_utils-0.1.0.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mamon_utils-0.1.0-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file mamon_utils-0.1.0.tar.gz.

File metadata

  • Download URL: mamon_utils-0.1.0.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.9.17 Linux/5.15.0-78-generic

File hashes

Hashes for mamon_utils-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c7ced38a57f226192f0d6164069b531c8a14307e70a2de7145875ef02c14b7bb
MD5 4950e5b697cd04a97f32eb81d0ba0e5c
BLAKE2b-256 47a365d7c2202a12967bec64fd0346fcf7874412eda005efec495141baa1f3d7

See more details on using hashes here.

File details

Details for the file mamon_utils-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mamon_utils-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.9.17 Linux/5.15.0-78-generic

File hashes

Hashes for mamon_utils-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 601bc0e2567000acd7adb6fd2b7d1acca21213b330a669fc9cee5564a0c7f153
MD5 ac00525746f52db660b4f223704a3498
BLAKE2b-256 9b444903a755e19c7119f8975f9534f999a7f0d1b368bbd5285759393a8034f8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page