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
- 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'
)
- 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)
- 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
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dbops_manager-0.1.1.tar.gz.
File metadata
- Download URL: dbops_manager-0.1.1.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6daaaad5036d48495101fa48190a23a4fffc63e78f5395ea1560593d94ee8546
|
|
| MD5 |
34c364ca385e487f8dac50eef83e1294
|
|
| BLAKE2b-256 |
3a4d13b1356f35867a8c24d255c9f5c5d4f72dcca0b8d847fd3a1725031221da
|
File details
Details for the file dbops_manager-0.1.1-py3-none-any.whl.
File metadata
- Download URL: dbops_manager-0.1.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e5335f5f1345b2076190d77a6cb543b8e91d70f274f6f6034f2b65e48f6dca6
|
|
| MD5 |
e0d59f048db105b05c9b6e360aa63e47
|
|
| BLAKE2b-256 |
a85044eab46c06269d3946de020375dccadd4657a5a5cc47c1848ded7e28d390
|