Skip to main content

A lightweight PostgreSQL operations manager for AWS Lambda

Project description

dbops-manager

A flexible database operations manager supporting multiple databases with a focus on PostgreSQL.

Features

  • Modular database operations system
  • PostgreSQL support with SQLAlchemy
  • Flexible configuration through environment variables or programmatic setup
  • Type-safe operations with proper error handling
  • Singleton pattern for database connections
  • Clean and extensible interface for database operations

Installation

pip install dbops-manager

Quick Start

  1. Set up your database configuration either through environment variables or programmatically:
from dbops_manager import settings

# Method 1: Using environment variables (.env file)
# DB_HOST=localhost
# DB_PORT=5432
# DB_USERNAME=postgres
# DB_PASSWORD=postgres
# DB_NAME=example

# Method 2: Configure programmatically
settings.configure(
    db_host='localhost',
    db_port=5432,
    db_username='postgres',
    db_password='postgres',
    db_name='example'
)
  1. Define your model:
from sqlalchemy import Column, Integer, String, DateTime
from sqlalchemy.ext.declarative import declarative_base
from datetime import datetime

Base = declarative_base()

class User(Base):
    __tablename__ = 'users'

    id = Column(Integer, primary_key=True)
    name = Column(String(100), nullable=False)
    email = Column(String(120), unique=True, nullable=False)
    created_at = Column(DateTime, default=datetime.utcnow)
    updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
  1. Use the database operations:
from dbops_manager import PostgresOperations

# Initialize with your model
db = PostgresOperations(User)

# Create users
db.create_users([
    {"name": "Alice", "email": "alice@example.com"},
    {"name": "Bob", "email": "bob@example.com"}
])

# List all users
db.list_all_users()

# Update a user
db.update_user_info(1, {"name": "Alice Smith"})

# Delete a user
db.delete_user_by_id(2)

Configuration

The package supports configuration through both environment variables and programmatic setup:

Environment Variables

  • DB_HOST: Database host (default: localhost)
  • DB_PORT: Database port (default: 5432)
  • DB_USERNAME: Database username (default: postgres)
  • DB_PASSWORD: Database password (default: postgres)
  • DB_NAME: Database name (default: example)

Programmatic Configuration

from dbops_manager import settings

settings.configure(
    db_host='localhost',
    db_port=5432,
    db_username='user',
    db_password='pass',
    db_name='mydb'
)

License

MIT License - see LICENSE file for details.

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

dbops_manager-0.1.2.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

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

dbops_manager-0.1.2-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file dbops_manager-0.1.2.tar.gz.

File metadata

  • Download URL: dbops_manager-0.1.2.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for dbops_manager-0.1.2.tar.gz
Algorithm Hash digest
SHA256 741cd99fe9d6d3b56008a81dfb0816786d39a18f34e2a607a0385c47903cfaa5
MD5 e6279eff7718044caac35185963e0f25
BLAKE2b-256 b72eefca9ec178203b52e9cb83bb7f2b78d96e4ac2caabc988d0b1ad69ecb6b4

See more details on using hashes here.

File details

Details for the file dbops_manager-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: dbops_manager-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for dbops_manager-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6b096414fa21abd5c76e9b76387849c539153fb2560e0a1b4f607a285c249772
MD5 b1e1277c467243a4ee99691e8163546b
BLAKE2b-256 8caa4ce97247c7d7593b96befdf1d7126937579cf6929f99e5c6a029b29fedef

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