No project description provided
Project description
mongolite
Lite mongodb engine in python
pip install pymongolite
Examples
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:
- insert_many / insert_one
- update_many / update_one
- $set
- $unset
- $inc
- $addToSet
- $each
- $push
- $each
- $sort
- $slice
- $pull
- find / find_one
- field matching
- $eq
- $ne
- $gt / $gte
- $lt / $lte
- $not
- $and
- $or
- $nor
- $exists
- $in
- $nin
- filter fields
- replace_many / replace_one
- create_collection
- get_collection
- drop_collection
- create_database
- drop_database
- thread safety
- replaceable storage engine
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.3.tar.gz
(14.9 kB
view details)
Built Distribution
File details
Details for the file pymongolite-0.1.3.tar.gz
.
File metadata
- Download URL: pymongolite-0.1.3.tar.gz
- Upload date:
- Size: 14.9 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 | 71b04807edbdc9d614f6d3a6a595cf5362f03dd59598ea350667f53972edfa14 |
|
MD5 | 6cc296668f031cece33b24a431e6ae70 |
|
BLAKE2b-256 | db359c857961c08d3fcc20fe5a0feb50ffabe8d0300fa4969a9c4b118141d7fd |
File details
Details for the file pymongolite-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: pymongolite-0.1.3-py3-none-any.whl
- Upload date:
- Size: 22.0 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 | f565bffd78c68a897f6984b4667e56078ff9892aa9be0b31d5b0f9e7c7439065 |
|
MD5 | 311566a0862e2c68157259e7e251d668 |
|
BLAKE2b-256 | 1cfe5dbb8edac4d9b229314691983b158a92cbdd45cb5165b7cd81b4957efefd |