No project description provided
Project description
mongolite
Lite mongodb engine in python
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.2.tar.gz
(14.8 kB
view details)
Built Distribution
File details
Details for the file pymongolite-0.1.2.tar.gz
.
File metadata
- Download URL: pymongolite-0.1.2.tar.gz
- Upload date:
- Size: 14.8 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 | e7b7327e7a503002bef4397be1b5844208945257068186e953730cb89216cba1 |
|
MD5 | 36563d29aab61258fd0733f0a05ed13e |
|
BLAKE2b-256 | a8cfc2d75aeaf47ed9d401ad296ebf09ae52968c7669cc182c63175cf97b4008 |
File details
Details for the file pymongolite-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: pymongolite-0.1.2-py3-none-any.whl
- Upload date:
- Size: 21.9 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 | 4d83669e824b1dca63a273644a4cc0b5ddca98849b6e2ca38b95960bcdcf5c89 |
|
MD5 | 5f5b9a7a1d9b10b318d3068ddc346e2e |
|
BLAKE2b-256 | 06537e69080d3523365b2eced5bbfb0ecb4c0f14e17b8e4097f6650cb3bbfe74 |