Skip to main content

A simple PostgreSQL management package for handling databases, tables, columns, and rows.

Project description

PostgreSQL Manager

A simple PostgreSQL management package for handling databases, tables, columns, and rows with ease.

Features

  • Create and manage PostgreSQL databases
  • Create and modify tables
  • Add, update, and delete columns
  • Insert and manage rows
  • Easy-to-use API for database operations

Installation

Install the Package

Install the package using pip:

pip install postgresql_manager

Import the Package

from postgresql_manager import Manager, Databases, Tables, Columns, Rows

Configure the Database

# Configure the database connection
success = Manager.config(
    db_name="my_database",
    user_name="test_user",
    password="test_password",
    host="127.0.0.1",
    port="5432"
)

# Check if configuration was successful
if success:
    print("Configuration set successfully.")
else:
    print("Failed to set configuration.")

Usage

Databases

Check if a Database Exists

database_exists = Databases.exists("my_database")
print(f"Database exists: {database_exists}") # True or False

Create a Database

database_created = Databases.create("my_database")
print(f"Database created: {database_created}") # True or False

Delete a Database

database_deleted = Databases.delete("my_database")
print(f"Database deleted: {database_deleted}") # True or False

Tables

Check if a Table Exists

table_exists = Tables.exists("my_database", "users")
print(f"Table exists: {table_exists}") # True or False

Create a Table

table_created = Tables.create("my_database", "users")
print(f"Table created: {table_created}") # True or False

Delete a Table

table_deleted = Tables.delete("my_database", "users")
print(f"Table deleted: {table_deleted}") # True or False

Columns

Check If a Column Exists

column_exists = Columns.exists("my_database", "users", "name")
print(f"Column exists: {column_exists}") # True or False

Create a Column

columns_to_add = [
    {"name": "id", "type": "INT", "is_not_null": False, "is_primary": True},
    {"name": "first_name", "type": "VARCHAR", "is_not_null": True},
    {"name": "last_name", "type": "VARCHAR", "is_not_null": True, "comment": "User's last name"}
]
columns = Columns.create("my_database", "users", columns_to_add)
print(f"Columns: {columns}") # True or False

Delete a Column

column_deleted = Columns.delete("my_database", "users", "token")
print(f"Column deleted: {column_deleted}") # True or False

Rows

Check If a Row Exists

row_exists = Rows.exists("my_database", "users", 1)
print(f"Row exists: {row_exists}") # True or False

Create a Row

rows_to_add = [
    {"id": 1, "first_name": "Alice", "last_name": "Smith"},
    {"id": 2, "first_name": "Bob", "last_name": "Johnson"},
    {"id": 3, "first_name": "Charlie", "last_name": "Brown"},
]
row_created = Rows.create("my_database", "users", rows_to_add)
print(f"Row created: {row_created}") # True or False

Delete a Row

row_deleted = Rows.delete("my_database", "users", 1)
print(f"Row deleted: {row_deleted}") # True or False

Getting Help

If you have any questions or need assistance, feel free to open an issue.

Contributing

We welcome contributions! If you’d like to improve this project, follow these steps:

1. Fork the Repository

Click the "Fork" button on GitHub and clone your copy:

git clone https://github.com/ximilsoft/postgresql_manager.git
cd postgresql_manager

2. Create a New Branch

Create a feature branch for your work:

git checkout -b feature-new-functionality

3. Make Changes & Test

Modify the code and test locally.

4. Commit & Push

git add .
git commit -m "Added a new feature"
git push origin feature-new-functionality

5. Submit a Pull Request

Go to GitHub, open a pull request (PR), and describe your changes.

📅 Roadmap

  • Add database configuration.
  • Support for multiple databases.
  • Implement additional database operations.
  • Enhance scalability and performance optimization.

📜 License

This project is licensed under the MIT License.

Support

If you find this project helpful, show your support by starring the repository.

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

postgresql_manager-2.0.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

postgresql_manager-2.0.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file postgresql_manager-2.0.0.tar.gz.

File metadata

  • Download URL: postgresql_manager-2.0.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for postgresql_manager-2.0.0.tar.gz
Algorithm Hash digest
SHA256 1e26dc2fb2767a3752dcac25a74786da9da9c69211c3fdb973fec64b881e4cd3
MD5 73b9c5042d7f7920be73b774f05f4d0d
BLAKE2b-256 51d176649fd9fb2b8e3e9447791ee6b774aa1328f220b5dd4992f3f1283b511b

See more details on using hashes here.

File details

Details for the file postgresql_manager-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for postgresql_manager-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cf851ed629e4067c5ac336ff03b9659f3d05a5b12c366736c47ff8da2b58ba28
MD5 6464dc3608f245626aabb7fa1f653b4e
BLAKE2b-256 38d050ffd6a8a9153a5b83f9e4880eb93f2eea6cb2e6dbbd15a8ed40d1b83875

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