Skip to main content

A flexible database operations manager supporting multiple databases

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.0.tar.gz (9.5 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.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dbops_manager-0.1.0.tar.gz
  • Upload date:
  • Size: 9.5 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.0.tar.gz
Algorithm Hash digest
SHA256 5b70262d3fbc5db63eec6723656b19403f4a33b20e7fc52ece3e75b27308b5aa
MD5 34bd5d800baaf7669d4544720d408b0a
BLAKE2b-256 e4d631dbca954c7a24098e7376999897b168e471d18583ed63ba560d86569fab

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dbops_manager-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b3ebf31ed5f5059b6ff1baaa655af4d532f4e17c9eb026257adf53cb9dc44276
MD5 7afc79dd84c3c048fc95f5f069cf8820
BLAKE2b-256 d3dfff2782cbcc7d16604ddfbcdff4056df715298dad25e50094ff82133badb5

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