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 exploring its content:
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 (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/
├── users.json
│ └── ...
└── cheese.json
└── {
"cheese": [
{
"_id": 5590198231212309,
"name": "Camembert",
"price": 2.99,
"country": "France"
},
{
"_id": 5512398091283234,
"name": "Maroilles",
"price": 4.49,
"country": "France"
}
]
}
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.16.tar.gz
(7.3 kB
view hashes)
Built Distribution
Close
Hashes for mongonow-0.0.16-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1cc460d861bb698c97db0cc4fb734d0a5769efeed6aef6dd4edec5d37402814 |
|
MD5 | 7f2849e57e8e6005545ac2624497de6a |
|
BLAKE2b-256 | 2d9b85b37975bf29384f13d1901dab980cd1d0544a1f8b127d240b2a30eb4628 |