A routing package for Mongo DB
Project description
MongoRouter
===========
A thin wrapper over pymongo to make code independent of the database model.
----
The purpose of this package is to make code code independent of the database model.
Consider this code:
```python
client = MongoClient(host="mymongohost.com")
```
```python
db = client["db_name"]
```
```python
col = db["col_name"]
```
```python
col.insert_thing({"some": "thing"})
```
Changing the client host, or the name of the data base, or even the name of the collection would involve
refactoring every instance of these calls.
This project aims to solve this problem by separating the routing.
Suppose the code looked like this:
```python
settings = {
"routes": {
"col_name": {
"client": {
"host": "mymongohost.com",
"port": 27017
},
"db": "db_name",
"col": "col_name"
}
}
```
```python
router = MongoRouter(settings=settings)
```
```python
mongo_router.route("col_name").insert({"some": "thing"})
```
This would allow the host, database name and collection name to be changed independently of db calls, which would look
like this, always:
```python
mongo_router.route("col_name").insert({"some": "thing"})
```
Changing the data base model is as easy as changing a JSON.
===========
A thin wrapper over pymongo to make code independent of the database model.
----
The purpose of this package is to make code code independent of the database model.
Consider this code:
```python
client = MongoClient(host="mymongohost.com")
```
```python
db = client["db_name"]
```
```python
col = db["col_name"]
```
```python
col.insert_thing({"some": "thing"})
```
Changing the client host, or the name of the data base, or even the name of the collection would involve
refactoring every instance of these calls.
This project aims to solve this problem by separating the routing.
Suppose the code looked like this:
```python
settings = {
"routes": {
"col_name": {
"client": {
"host": "mymongohost.com",
"port": 27017
},
"db": "db_name",
"col": "col_name"
}
}
```
```python
router = MongoRouter(settings=settings)
```
```python
mongo_router.route("col_name").insert({"some": "thing"})
```
This would allow the host, database name and collection name to be changed independently of db calls, which would look
like this, always:
```python
mongo_router.route("col_name").insert({"some": "thing"})
```
Changing the data base model is as easy as changing a JSON.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for MongoRouter-0.0.1-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb0faa49d5349b9653e9b2576753728022a97cf6c9161376ba6a2479cddfdb90 |
|
MD5 | 595a87226fb3ade51ad36c3158ad078b |
|
BLAKE2b-256 | e81955507953870a174f1b4c26c6c8b1fa1bc0dfa405a71f9bfdc9183f1e8700 |