# mongolite
Lite mongodb engine in python
[![Run Tests](https://github.com/hvuhsg/mongolite/actions/workflows/test.yml/badge.svg)](https://github.com/hvuhsg/mongolite/actions/workflows/test.yml)
[![BringThemBack](https://badge.yehoyada.com/)](https://www.standwithus.com/)
---
```shell
pip install pymongolite
```
## Examples
#### simple
```python
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}
```
```python
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
```python
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
Raw data
{
"_id": null,
"home_page": "https://github.com/hvuhsg/mongolite",
"name": "pymongolite",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": "mongo, python, lite, local, simple, pymongo, NoSQL, db, database",
"author": "yehoyada",
"author_email": "yehoyada.sht@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/bb/0f/d2c403248fd557a6a5d9b0df5e253bc8f82a5a723256b238580a1fa79e43/pymongolite-0.1.7.tar.gz",
"platform": null,
"description": "# mongolite \nLite mongodb engine in python \n\n[![Run Tests](https://github.com/hvuhsg/mongolite/actions/workflows/test.yml/badge.svg)](https://github.com/hvuhsg/mongolite/actions/workflows/test.yml) \n[![BringThemBack](https://badge.yehoyada.com/)](https://www.standwithus.com/) \n\n---\n\n```shell\npip install pymongolite\n```\n\n## Examples\n\n#### simple \n```python\nfrom pymongolite import MongoClient\n\nwith MongoClient(dirpath=\"~/my_db_dir\", database=\"my_db\") as client:\n db = client.get_default_database()\n collection = db.get_collection(\"users\")\n\n collection.insert_one({\"name\": \"yoyo\"})\n collection.update_one({\"name\": \"yoyo\"}, {\"$set\": {\"age\": 20}})\n user = collection.find_one({\"age\": 20})\n print(user) # -> {\"_id\": ObjectId(...), \"name\": \"yoyo\", \"age\": 20}\n```\n\n```python\nfrom pymongolite import MongoClient\n\nclient = MongoClient(dirpath=\"~/my_db_dir\", database=\"my_db\")\n\ndb = client.get_default_database()\ncollection = db.get_collection(\"users\")\n\ncollection.insert_one({\"name\": \"yoyo\"})\ncollection.update_one({\"name\": \"yoyo\"}, {\"$set\": {\"age\": 20}})\nuser = collection.find_one({\"age\": 20})\nprint(user) # -> {\"_id\": ObjectId(...), \"name\": \"yoyo\", \"age\": 20}\n\nclient.close()\n```\n\n#### Indexes\n```python\nfrom pymongolite import MongoClient\n\nclient = MongoClient(dirpath=\"~/my_db_dir\", database=\"my_db\")\n\ndb = client.get_default_database()\ncollection = db.get_collection(\"users\")\n\n# Make query with name faster\ncollection.create_index({\"name\": 1})\n\ncollection.insert_one({\"name\": \"yoyo\"})\ncollection.update_one({\"name\": \"yoyo\"}, {\"$set\": {\"age\": 20}})\nuser = collection.find_one({\"age\": 20})\nprint(user) # -> {\"_id\": ObjectId(...), \"name\": \"yoyo\", \"age\": 20}\n\nindexes = collection.get_indexes()\nprint(indexes) # -> [{'id': UUID('8bb4cac8-ae52-4fff-9e69-9f36a99956cd'), 'field': 'age', 'type': 1, 'size': 1}]\n\nclient.close()\n```\n\n## Support\nThe goal of this project is to create sqlite version for mongodb\n\n### For now the library is supporting:\n#### actions:\n- database\n - create_database\n - get_database\n - drop_database\n- collection\n - create_collection\n - get_collection\n - drop_collection\n - get_collection_names\n- index\n - create_index\n - delete_index\n - get_indexes\n- document\n - insert_many / insert_one\n - update_many / update_one\n - find / find_one\n - replace_many / replace_one\n#### filtering ops:\n- field matching\n- $eq / $ne\n- $gt / $gte\n- $lt / $lte\n- $not\n- $and / $or / $nor\n- $exists\n- $in / $nin\n#### mutation ops:\n- $set\n- $unset\n- $inc\n- $addToSet\n - $each\n- $push\n - $each\n - $sort\n - $slice\n- $pull\n",
"bugtrack_url": null,
"license": null,
"summary": null,
"version": "0.1.7",
"project_urls": {
"Homepage": "https://github.com/hvuhsg/mongolite",
"Repository": "https://github.com/hvuhsg/mongolite"
},
"split_keywords": [
"mongo",
" python",
" lite",
" local",
" simple",
" pymongo",
" nosql",
" db",
" database"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ffcd63feb330612eff634b3a3469fa63fe7f82940aff1f20b55bbd668cadf4ed",
"md5": "83932b4cd4bf854f68c15e8af335334a",
"sha256": "9eb4ce95f5a64da351c40dc054e8107bbb0468b472f5c312b5d14cee3f3e3bd3"
},
"downloads": -1,
"filename": "pymongolite-0.1.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "83932b4cd4bf854f68c15e8af335334a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 25019,
"upload_time": "2024-05-13T16:18:33",
"upload_time_iso_8601": "2024-05-13T16:18:33.639677Z",
"url": "https://files.pythonhosted.org/packages/ff/cd/63feb330612eff634b3a3469fa63fe7f82940aff1f20b55bbd668cadf4ed/pymongolite-0.1.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "bb0fd2c403248fd557a6a5d9b0df5e253bc8f82a5a723256b238580a1fa79e43",
"md5": "98cc6002c64baa1ab146827681aafdb3",
"sha256": "2cdee4d9d361c633a357d44162be298f25e9e66443571810600611b82ad216d3"
},
"downloads": -1,
"filename": "pymongolite-0.1.7.tar.gz",
"has_sig": false,
"md5_digest": "98cc6002c64baa1ab146827681aafdb3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 16831,
"upload_time": "2024-05-13T16:18:36",
"upload_time_iso_8601": "2024-05-13T16:18:36.355642Z",
"url": "https://files.pythonhosted.org/packages/bb/0f/d2c403248fd557a6a5d9b0df5e253bc8f82a5a723256b238580a1fa79e43/pymongolite-0.1.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-13 16:18:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hvuhsg",
"github_project": "mongolite",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pymongolite"
}