Metadata-Version: 2.1
Name: dbgenie
Version: 0.0.1
Summary: A python package for automating database operations.
Home-page: https://github.com/hrshankar2002/DBGenie
Author: hrshankar2002
Author-email: hrshankar2002@gmail.com
License: MIT
Project-URL: Bug Tracker, https://github.com/hrshankar2002/DBGenie/issues
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Requires-Dist: psycopg2-binary
Requires-Dist: mysql-connector-python
Requires-Dist: pymongo
Requires-Dist: pymongo[srv]
Requires-Dist: dnspython
Requires-Dist: ensure
Requires-Dist: pytest==7.1.3
Requires-Dist: tox
Requires-Dist: black==22.8.0
Requires-Dist: flake8==5.0.4
Requires-Dist: mypy==0.971
Provides-Extra: testing
Requires-Dist: pytest>=7.1.3; extra == "testing"
Requires-Dist: mypy>=0.971; extra == "testing"
Requires-Dist: flake8>=5.0.4; extra == "testing"
Requires-Dist: tox>=3.25.1; extra == "testing"
Requires-Dist: black>=22.8.0; extra == "testing"

# DBGenie

DBGenie is a Python package that provides classes for automating database operations on MongoDB, PostgreSQL, and MySQL databases. The package provides easy-to-use classes that encapsulate common database operations, allowing developers to focus on building their applications rather than dealing with low-level database interactions.

## Installation

***You can install DBGenie using pip:***

```bash
pip install DBGenie
```
## Key Features

- Support for Multiple Databases: DBGenie has support to MongoDB, PostgreSQL, and MySQL databases, providing a unified interface for CRUD operations across different database systems.

- Simple and Intuitive API: The package offers a straightforward API for performing CRUD operations, making it easy for developers to interact with databases without needing to write complex SQL queries or MongoDB commands.

- Automatic Connection Management: DatabaseCRUD handles database connection management, including connecting to the database, executing queries, and closing connections, ensuring efficient resource usage and preventing memory leaks.

- Flexible and Extensible: The package is designed to be flexible and extensible, allowing developers to customize and extend functionality as needed for their specific use cases.

## Workflow
DBGenie provides separate classes for each supported database system:

- MongoDBCrud:  for MongoDB databases
- PostgreSQLCrud: for PostgreSQL databases
- MySQLCrud: for MySQL databases

Each class encapsulates the common CRUD operations for its respective database system, including:

- Inserting documents/records
- Finding documents/records
- Updating documents/records
- Deleting documents/records

Developers can instantiate these classes, configure connection parameters, and use the provided methods to interact with their databases seamlessly.

## Usage
### 1. MongoDB
#### 1.1 CRUD Operations
```bash
from DatabaseCRUD import MongoDBCRUD

# Connect to MongoDB
mongodb_crud = MongoDBCRUD(uri="mongodb://localhost:27017", database="my_database", collection="my_collection")

# Insert document
mongodb_crud.insert_document({"name": "John", "age": 30})

# Find document
document = mongodb_crud.find_document({"name": "John"})
print(document)

# Update document
mongodb_crud.update_document({"name": "John"}, {"age": 35})

# Delete document
mongodb_crud.delete_document({"name": "John"})
```
### 2. PostgreSQl
#### 2.1 CRUD Operations
```bash
from DatabaseCRUD import PostgreSQLCrud

# Connect to PostgreSQL
postgresql_crud = PostgreSQLCrud(host="localhost", user="postgres", password="password", database="my_database")

# Create table
postgresql_crud.create_table("my_table", ["id SERIAL PRIMARY KEY", "name VARCHAR(255)", "age INT"])

# Insert record
postgresql_crud.insert_record("my_table", (1, "John", 30))

# Read records
records = postgresql_crud.read_records("my_table")
print(records)

# Update record
postgresql_crud.update_record("my_table", {"age": 35}, "name='John'")

# Delete record
postgresql_crud.delete_record("my_table", "name='John'")
```
### 3. MySQL
#### 3.1 CRUD Operations
```bash
from DatabaseCRUD import MySQLCrud

# Connect to MySQL
mysql_crud = MySQLCrud(host="localhost", user="root", password="password", database="my_database")

# Create table
mysql_crud.create_table("my_table", ["id INT AUTO_INCREMENT PRIMARY KEY", "name VARCHAR(255)", "age INT"])

# Insert record
mysql_crud.insert_record("my_table", (1, "John", 30))

# Read records
records = mysql_crud.read_records("my_table")
print(records)

# Update record
mysql_crud.update_record("my_table", {"age": 35}, "name='John'")

# Delete record
mysql_crud.delete_record("my_table", "name='John'")
```
## Contributing

Contributions to DBGenie are welcome! If you have ideas for new features, improvements, or bug fixes, please feel free to open an issue or submit a pull request. See the Contributing Guidelines for more information.

- Fork the repository
- Create your feature branch (git checkout -b feature/YourFeature)
- Commit your changes (git commit -m 'Add some feature')
- Push to the branch (git push origin feature/YourFeature)
- Create a new Pull Request

## License
DBGenie is licensed under the MIT License. See the LICENSE file for details.


