Skip to main content

No project description provided

Project description

mongolite

Lite mongodb engine in python

Run Tests


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.5.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

pymongolite-0.1.5-py3-none-any.whl (25.2 kB view details)

Uploaded Python 3

File details

Details for the file pymongolite-0.1.5.tar.gz.

File metadata

  • Download URL: pymongolite-0.1.5.tar.gz
  • Upload date:
  • Size: 16.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

Hashes for pymongolite-0.1.5.tar.gz
Algorithm Hash digest
SHA256 532d47ac6ab2d6419a4bd9009fd9f9af7706f332bd8069c6dd2a648b4ca34cd6
MD5 b7a08a4f82e18b490715566b7215a80c
BLAKE2b-256 040882f3cbcd662f53470ab7d8d84557b6598893862ab08d6830c6f7aeddd604

See more details on using hashes here.

File details

Details for the file pymongolite-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: pymongolite-0.1.5-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

Hashes for pymongolite-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 cd15de11212b58ffc37ad1eeb71290b77fe5669268c498e1a0f4380cf6ac6cca
MD5 b9ae0a04c52be9e5371d88d1c613890f
BLAKE2b-256 da39aae1a472d166fc51b6899ad632b029b60e8ec5751d53772685b2dee10bb0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page