No project description provided
Project description
mongolite
Lite mongodb engine in python
pip install pymongolite
Examples
simple
from pymongolite import MongoClient
with MongoClient(dirpath="~/my_db_dir", database="my_db") as client:
db = client.get_default_database()
collection = db.get_collection("users")
collection.insert_one({"name": "yoyo"})
collection.update_one({"name": "yoyo"}, {"$set": {"age": 20}})
user = collection.find_one({"age": 20})
print(user) # -> {"_id": ObjectId(...), "name": "yoyo", "age": 20}
from pymongolite import MongoClient
client = MongoClient(dirpath="~/my_db_dir", database="my_db")
db = client.get_default_database()
collection = db.get_collection("users")
collection.insert_one({"name": "yoyo"})
collection.update_one({"name": "yoyo"}, {"$set": {"age": 20}})
user = collection.find_one({"age": 20})
print(user) # -> {"_id": ObjectId(...), "name": "yoyo", "age": 20}
client.close()
Indexes
from pymongolite import MongoClient
client = MongoClient(dirpath="~/my_db_dir", database="my_db")
db = client.get_default_database()
collection = db.get_collection("users")
# Make query with name faster
collection.create_index({"name": 1})
collection.insert_one({"name": "yoyo"})
collection.update_one({"name": "yoyo"}, {"$set": {"age": 20}})
user = collection.find_one({"age": 20})
print(user) # -> {"_id": ObjectId(...), "name": "yoyo", "age": 20}
indexes = collection.get_indexes()
print(indexes) # -> [{'id': UUID('8bb4cac8-ae52-4fff-9e69-9f36a99956cd'), 'field': 'age', 'type': 1, 'size': 1}]
client.close()
Support
The goal of this project is to create sqlite version for mongodb
For now the library is supporting:
actions:
- database
- create_database
- get_database
- drop_database
- collection
- create_collection
- get_collection
- drop_collection
- get_collection_names
- index
- create_index
- delete_index
- get_indexes
- document
- insert_many / insert_one
- update_many / update_one
- find / find_one
- replace_many / replace_one
filtering ops:
- field matching
- $eq / $ne
- $gt / $gte
- $lt / $lte
- $not
- $and / $or / $nor
- $exists
- $in / $nin
mutation ops:
- $set
- $unset
- $inc
- $addToSet
- $each
- $push
- $each
- $sort
- $slice
- $pull
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
pymongolite-0.1.6.tar.gz
(17.0 kB
view details)
Built Distribution
File details
Details for the file pymongolite-0.1.6.tar.gz
.
File metadata
- Download URL: pymongolite-0.1.6.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.8.10 Linux/5.13.0-40-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49662e1d19f0caea3cea401d68a245c3079ab13c51701ae1d7d3a5e30fb64828 |
|
MD5 | 7da1b1e18c38735ce5c2c5953ba6166c |
|
BLAKE2b-256 | 52c95d86f496d1f812b197eb10f41370ac02f7053feec153138982bb4dbcb7e7 |
File details
Details for the file pymongolite-0.1.6-py3-none-any.whl
.
File metadata
- Download URL: pymongolite-0.1.6-py3-none-any.whl
- Upload date:
- Size: 25.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.8.10 Linux/5.13.0-40-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4df883d14b4232295c78b9b74551f573a4f88f255f26ba9dfcd3456b1d0b61a2 |
|
MD5 | 1290a81252418fad215b5fd6eeef242f |
|
BLAKE2b-256 | 124d5a966f50a0edb6c298e05c98b4ad32ac0e72bb44e0e37df6b9e63b2e719a |