MongoNow is the equivalent of sqlite for MongoDB. It's a local in-memory mongo-like database.
Project description
Are you unsatisfied of working with mock data in dev environment ?
MongoNow is here to help.
Do you wonder if there is a quick way of setting up a dummy MongoDB instance in less that seconds?
With MongoNow, all your problems have finally found a solution.
Install MongoNow with pip
or git
and your Mongo-like database
is ready to be used in seconds.
Installation
Install the MongoNow package with python-pip or clone it from github.
Install using pip:
$ pip install mongonow
Install using git:
$ git clone https://github.com/AlexandreMahdhaoui/MongoNow.git
Usage:
- Create a MongoNowClient instance and start
from mongonow import MongoNowClient
# Create a MongoNowClient specifying the path of your databases.
client = MongoNowClient(path='/dbs')
# Select one of your database
db = client['test_db']
# Select a collection
cheese_collection = db['cheese']
- Perform a query on your collection with the same syntax you would use for MongoDB:
# SELECT all FROM cheese documents WHERE price is less than 4.99 AND country is France
>>> cheese_collection.find({
.... '$and': [
.... {'$lt': {'price': '4.99'}},
.... {'$eq': {'country': 'France'}} # or {'country: 'France'} without $eq
.... ]
.... })
Iterator([
{
"_id": 5590198231212309,
"name": "Camembert",
"price": 2.99,
"country": "France"
},
{
"_id": 5512398091283234,
"name": "Maroilles",
"price": 4.49,
"country": "France"
}
])
- Mutate several documents
# Set field discounted to True for all french cheese
cheese_collection.update_many(
{"country": "France"},
{"discounted": True}
)
File Structure
The structure of the local database should be conform to the MongoNow's file structure Specification.
- The Database Container named whatever you want (e.g.
dbs/
) containing all databases. The path of this folder has to be specified during MongoNowClient instanciation:client = MongoNowClient(path='/dbs')
- Database folders (e.g.
test_db/
) containing all its collection. Navigate to this database withdb = client['test_db']
. - Collection files (e.g.
cheese.json
): Navigate to this collection withcoll = db['cheese']
.
...
└── dbs/
├── dev_db/
│ └── ...
└── test_db/
├── cheese.json
│ ├── {
│ │ "cheese": [
│ │ {
│ │ "_id": 5590198231212309,
│ │ "name": "Camembert",
│ │ "price": 2.99,
│ │ "country": "France"
│ │ },
│ │ {
│ │ "_id": 5512398091283234,
│ │ "name": "Maroilles",
│ │ "price": 4.49,
│ │ "country": "France"
│ │ }
│ │ ]
└── users.json
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mongonow-0.0.15.tar.gz
(7.3 kB
view hashes)
Built Distribution
Close
Hashes for mongonow-0.0.15-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ee4cce010c76429af5b9f60e85b3360e07853e641b455dd1bea9ba55c8d73db |
|
MD5 | c32c4490a311f230f1c1a1c56060d40d |
|
BLAKE2b-256 | e99ac9807f8000ba8d1d7b3c2bb809fd92d188743e79b5001ff0ce7c14b93637 |