Skip to main content

A python package for connecting with database.

Project description

Auto_connect_mongo

A Python package for connecting to MongoDB and performing basic CRUD operations.


Installation

pip install Auto_connect_mongo

Or, to install from source:

git clone https://github.com/AnandVadgama/my-py-package.git
cd my-py-package
pip install -r requirements.txt

Usage

Connect to MongoDB

from Auto_connect_mongo.mongo_crud import mongo_operation

client_url = "mongodb+srv://<username>:<password>@cluster0.mongodb.net/"
database_name = "my_database"
collection_name = "my_collection"

mongo_op = mongo_operation(client_url, database_name, collection_name)

Insert a Record

record = {"name": "Alice", "age": 30}
mongo_op.insert_record(record, collection_name)

Find Records

query = {"age": {"$gt": 25}}
results = mongo_op.find_record(query, collection_name)
for doc in results:
    print(doc)

Update a Record

query = {"name": "Alice"}
update = {"$set": {"age": 31}}
mongo_op.update_record(query, update, collection_name)

Delete a Record

query = {"name": "Alice"}
mongo_op.delete_record(query, collection_name)

Requirements

  • Python 3.7+
  • MongoDB instance (local or Atlas)

Testing

pip install -r requirements_dev.txt
pytest

For more details, see the source code or open an issue on GitHub.

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

auto_connect_mongo-0.0.8.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

auto_connect_mongo-0.0.8-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file auto_connect_mongo-0.0.8.tar.gz.

File metadata

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

File hashes

Hashes for auto_connect_mongo-0.0.8.tar.gz
Algorithm Hash digest
SHA256 f220fb4b7b0c31113cddc712b2bdbbfe70e02db54c62f0a5bd357443800af4aa
MD5 ade0517bceaf61d98ba6b0b70bc3df0f
BLAKE2b-256 77faec5a3703d641c4a2b42c70717964eec7609f8f40ec19b663f05b26e247e1

See more details on using hashes here.

File details

Details for the file auto_connect_mongo-0.0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for auto_connect_mongo-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 bd87e0be1006efea4966300303175286d477d88c3611531e23b4119c5d5349c5
MD5 f146d390fcc2bcdf45c38b350f7031a8
BLAKE2b-256 755bde3010177f94705c82f1aba36c595ac1fa5177da7f962fea053dd803eaaa

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