Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.

Latest commit

History

93 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation


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:

fromquickmongoimportDatabase# If you are using locallydb=Database('mongodb://localhost:27017/', {'db_name': 'local'})
# if you are using 'mongodb+srv://' uri then you should do something like thisdb=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 linkprint(db.all_database_names())
# Check if the given database exists in the listprint(db.database_exists('Cluster0'))
# Get all collections names under the linkprint(db.all_collection_names())
# Check if the given collection exists in the listprint(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 dictdb.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() functiondb.set('foo', 1) # Simple set function given description abovedb.add('foo', 2) # Will add 2 to the old value. So the current value will be 3db.subtract('foo', 1) # Will subtract 1 from old value of the key 'foo'. So the current value will be 1db.math('foo', '*', 5) # Will multiply value by 5 so 1*5 = 5db.math('foo', '**', 5) # 5**5 = 25db.math('foo', '/', 5) # 25/5 = 5db.math('foo', '+', 1) # 5+1 = 6db.math('foo', '-', 1) # 6-1 = 5db.typeof('foo') # Its currently int so it will return <class 'int'>

Contribute codes to this packages by github here

Support

About

A simple and quick wrapper for pymongo!

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages