Skip to main content

A python package for connecting with database.

Project description

databseautomationhuz

This is a lightweight Python package that simplifies working with MongoDB. It provides an easy-to-use interface for creating clients, connecting to databases, managing collections, inserting single or multiple records, and performing bulk inserts directly from CSV or Excel files. With built-in type safety checks and automatic handling of database/collection creation, it reduces boilerplate code and prevents common errors when interacting with MongoDB. Ideal for data engineering, ETL pipelines, and machine learning projects that require structured data storage and quick dataset imports into MongoDB.

Example Usage

# !pip install databaseautomationhuz
from databaseautomationhuz.mongo_crud import MongoOperation

# Step 1: Initialize the MongoOperation object
mongo = MongoOperation(
    client_url="mongodb+srv://huzaifaahmedzaidi:@cluster0.yipsi0i.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0",
    database_name="firstmongodbconnection"
)

# Step 2: Create collection
collection = mongo.create_collection("my_collection2")

# Step 3: Insert a single record
mongo.insert_record(
    record={"name": "Huzaifa", "age": 24, "role": "ML Engineer"},
    collection_name="my_collection2"
)

# Step 4: Insert multiple records
mongo.insert_record(
    record=[
        {"name": "Ali", "age": 25, "role": "Data Scientist"},
        {"name": "Sara", "age": 22, "role": "Developer"}
    ],
    collection_name="my_collection2"
)

# Step 5: Bulk insert from CSV (students.csv should be in same folder)
# mongo.bulk_insert("students.csv", "my_collection2")

print("All data inserted successfully!")

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

databaseautomationhuz-0.0.12.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

databaseautomationhuz-0.0.12-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file databaseautomationhuz-0.0.12.tar.gz.

File metadata

  • Download URL: databaseautomationhuz-0.0.12.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for databaseautomationhuz-0.0.12.tar.gz
Algorithm Hash digest
SHA256 c8fa4267cdd939abf55b09096a6d8e540753340fd3ffa11d890a14841abcd97c
MD5 46d35427ee176f5035e28c40bc3b3abf
BLAKE2b-256 579411d20fbd6948165b601e22291e6c3e3fd720f315ec9f10fc075c1b558a9d

See more details on using hashes here.

File details

Details for the file databaseautomationhuz-0.0.12-py3-none-any.whl.

File metadata

File hashes

Hashes for databaseautomationhuz-0.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 78c98a4d54629358ec71274b9e692b6379e3178761388dd10f1b3f04fca87f5d
MD5 f2491349ad811e72047444eb694f323d
BLAKE2b-256 fa35517dd3172cc355220659e2597b920114d5577bbd9c435402c9377b9b040f

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