Skip to main content

A simple and quick wrapper for pymongo!

Project description


Quick Intro

Quickmongo.py is a quick wrapper for pymongo to access mongodb! You can use pymongo if you know it!

Quick Docs

Installation

In your terminal:

pip install quickmongo.py

In your python file:

from quickmongo import Database

# If you are using locally
db = Database('mongodb://localhost:27017/', {'db_name': 'local'})

# if you are using 'mongodb+srv://' uri then you should do something like this
db = Database(mongoURL)
# mongourl will be the 'mongodb+srv://' uri link
# clusterName will be the name of the mongoose cluster. Eg:- Cluster0
# Incase if you don't know what is your clustername you will get an TypeError with available clusters!

Options of Databases

Set some options for your database as a dict which is optional

options = {
    'collection_name': 'yourCollectionName', # Collection name will be 'python' as default
    'db_name': 'Cluster0' # This is optional unless you are using localhost you have to set it to local!
}

db = Database(mongoURL, options)
# mongoURL is described above

Get databases and collections

# Get all database names under the link
print(db.all_database_names())
# Check if the given database exists in the list
print(db.database_exists('Cluster0'))

# Get all collections names under the link
print(db.all_collection_names())
# Check if the given collection exists in the list
print(db.collection_exists('python'))

All Operations

db.set('foo', 'bar') # Will set value 'bar' for the key 'foo'
db.get('foo') # Will return 'bar' which is the value of the key 'foo'

db.all() # Will return all keys and values of the collection! {'key': 'foo', 'value': 'bar'} as a dict
db.startswith('f') # Will sort all data whose keys startswith 'f' as {'key': 'foo', 'value': 'bar'}

db.delete('foo') # Will delete value of the key 'foo'
db.delete_all() # Will delete all values of the all keys! Simple drop() function

db.set('foo', 1) # Simple set function given description above

db.add('foo', 2) # Will add 2 to the old value. So the current value will be 3
db.subtract('foo', 1) # Will subtract 1 from old value of the key 'foo'. So the current value will be 1

db.math('foo', '*', 5) # Will multiply value by 5 so 1*5 = 5
db.math('foo', '**', 5) # 5**5 = 25
db.math('foo', '/', 5) # 25/5 = 5
db.math('foo', '+', 1) # 5+1 = 6
db.math('foo', '-', 1) # 6-1 = 5

db.typeof('foo') # Its currently int so it will return <class 'int'>

Events

Events are functions which will trigger on paticular times

Ready Event:

def ready():
    print('Connected with database')

db = Database(
    mongoURL='your-url',
    events={
        'ready': ready
    }
)

# Will run ready callback when db is ready!

Contribute codes to this packages by github here

Support

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

quickmongo.py-1.0.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

quickmongo.py-1.0.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file quickmongo.py-1.0.0.tar.gz.

File metadata

  • Download URL: quickmongo.py-1.0.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.5.0

File hashes

Hashes for quickmongo.py-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9838bd258bb4ebfd76bb9d8952a3ec6d54b3f0f64330e49fb4e0aabb54544049
MD5 a8427de00b6264e50a7e6ce1a6ab793f
BLAKE2b-256 cf3e35c7ed7214ffa1f6420ff827a3f611d2c3c247e5c913d70fb6326b1b7f84

See more details on using hashes here.

File details

Details for the file quickmongo.py-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: quickmongo.py-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.5.0

File hashes

Hashes for quickmongo.py-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 04cc58ca8237f59763c18f0ed746100972a7840cbf592396bd22a5e0d6ca8d14
MD5 c1fe4852bb1380ff23b195b3f23a27cf
BLAKE2b-256 90fe8d3650915a6b17721a6637c7508ffa45858314d96e15ab4d10587de9b5e0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page