https://github.com/scottrogowski/mongita Skip to content Sign up Sign up * Why GitHub? Features - + Mobile - + Actions - + Codespaces - + Packages - + Security - + Code review - + Project management - + Integrations - + GitHub Sponsors - + Customer stories- * Team * Enterprise * Explore + Explore GitHub - Learn and contribute + Topics - + Collections - + Trending - + Learning Lab - + Open source guides - Connect with others + The ReadME Project - + Events - + Community forum - + GitHub Education - + GitHub Stars program - * Marketplace * Pricing Plans - + Compare plans - + Contact Sales - + Education - [ ] [search-key] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this user All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up Sign up {{ message }} scottrogowski / mongita * Notifications * Star 48 * Fork 1 "Mongita is to MongoDB as SQLite is to SQL" BSD-3-Clause License 48 stars 1 fork Star Notifications * Code * Issues 0 * Pull requests 0 * Actions * Projects 0 * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Security * Insights master Switch branches/tags [ ] Branches Tags Nothing to show {{ refName }} default View all branches Nothing to show {{ refName }} default View all tags 1 branch 0 tags Go to file Code Clone HTTPS GitHub CLI [https://github.com/s] Use Git or checkout with SVN using the web URL. [gh repo clone scottr] Work fast with our official CLI. Learn more. * Open with GitHub Desktop * Download ZIP Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Go back Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Go back Launching Xcode If nothing happens, download Xcode and try again. Go back Launching Visual Studio If nothing happens, download the GitHub extension for Visual Studio and try again. Go back Latest commit @scottrogowski scottrogowski fix primary key on sqlite benchmark ... d71d59e Apr 20, 2021 fix primary key on sqlite benchmark d71d59e Git stats * 44 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time assets fix primary key on sqlite benchmark Apr 20, 2021 benchmark_tests fix primary key on sqlite benchmark Apr 20, 2021 mongita add SQLite JSON benchmark, small name change disk_engine Apr 20, 2021 tests tested not-present document fields Apr 18, 2021 .gitignore small cleanup Apr 17, 2021 LICENSE moved project. First commit Mar 25, 2021 Makefile minor tweaks for pypi Apr 19, 2021 README.md README update version Apr 19, 2021 requirements_dev.txt benchmarks on README Apr 17, 2021 setup.py minor tweaks for pypi Apr 19, 2021 View code Applications Design goals When NOT to use Mongita Installation Hello world Performance API Contributing License History Similar projects README.md Mongita Logo Version 0.1.0 Build passing Coverage 100% License BSD Mongita is a lightweight embedded document database that implements a commonly-used subset of the MongoDB/PyMongo interface. Mongita differs from MongoDB in that instead of being a server, Mongita is a self-contained Python library. Mongita can be configured to store its documents either on disk or in memory. "Mongita is to MongoDB as SQLite is to SQL" Mongita is in active development. Please report any bugs. Mongita is free and open source. You can contribute! Applications * Embedded database: Mongita is a good alternative to SQLite for embedded applications when a document database makes more sense than a relational one. * Unit testing: Mocking PyMongo/MongoDB is a pain. Worse, mocking can hide real bugs. By monkey-patching PyMongo with Mongita, unit tests can be more faithful while remaining isolated. Design goals * MongoDB compatibility: Mongita implements a commonly-used subset of the PyMongo API. This allows projects to be started with Mongita and later upgraded to MongoDB once they reach an appropriate scale. * Embedded/self-contained: Mongita does not require a server or start a process. It is just a Python library. To use it, just add import mongita to the top of your script. * Speed: Mongita is comparable-to or faster than both MongoDB and Sqlite in 10k document benchmarks. See the performance section below. * Well tested: Mongita has 100% test coverage and more test code than library code. * Limited dependencies: Mongita runs anywhere that Python runs. Currently the only dependencies are pymongo (for bson) and sortedcontainers (for faster indexes). * Thread-safe: (EXPERIMENTAL) Mongita avoids race conditions by isolating certain document modification operations. When NOT to use Mongita * You need a traditional server/client relationship: Mongita is an embedded database. It is not process-safe. When you have multiple clients, a traditional server/client database is the correct choice. * You run a lot of uncommon commands: Mongita implements a commonly used subset of MongoDB. While the goal is to eventually implement most of it, it will take some time to get there. * You need extreme performance: Mongita has comparable performance to MongoDB and SQLite for common operations. However, it's possible you'll find bottlenecks - especially with uncommon operations. Installation pip3 install mongita Hello world >>> from mongita import MongitaClientDisk >>> client = MongitaClientDisk() >>> hello_world_db = client.hello_world_db >>> mongoose_types = hello_world_db.mongoose_types >>> mongoose_types.insert_many([{'name': 'Meercat', 'not_into', 'Snakes'}, {'name': 'Yellow mongoose': 'eats': 'Termites'}]) InsertResult() >>> mongoose_types.count_documents({}) 2 >>> mongoose_types.update_one({'name': 'Meercat'}, {'$set': {"weight": 2}}) UpdateResult() >>> mongoose_types.find({'weight': {'$gt': 1}) Cursor() >>> list(coll.find({'weight': {'$gt': 1})) [{'_id': 'a1b2c3d4e5f6', 'weight': 2, 'name': 'Meercat'}] >>> coll.delete_one({'name': 'Meercat'}) DropResult() Performance Inserts and access Finds Updates and deletes Cold start API Refer to the PyMongo docs for detailed syntax and behavior. Most named keyword parameters are not implemented. When something is not implemented, efforts are made to be loud and obvious about it. mongita.MongitaClientMemory / mongita.MongitaClientDisk (PyMongo docs ) mongita.MongitaClient.close() mongita.MongitaClient.list_database_names() mongita.MongitaClient.list_databases() mongita.MongitaClient.drop_database(name_or_database) Database (PyMongo docs) mongita.Database.list_collection_names() mongita.Database.list_collections() mongita.Database.drop_collection(name_or_collection) Collection (PyMongo docs) mongita.Collection.insert_one(document) mongita.Collection.insert_many(documents, ordered=True) mongita.Collection.find_one(filter, sort) mongita.Collection.find(filter, sort, limit) mongita.Collection.replace_one(filter, replacement, upsert=False) mongita.Collection.update_one(filter, update) mongita.Collection.update_many(filter, update) mongita.Collection.delete_one(filter) mongita.Collection.delete_many(filter) mongita.Collection.count_documents(filter) mongita.Collection.distinct(key, filter) mongita.Collection.create_index(keys) mongita.Collection.drop_index(index_or_name) mongita.Collection.index_information() Cursor (PyMongo docs) mongita.Cursor.sort(key_or_list, direction=None) mongita.Cursor.next() mongita.Cursor.limit(limit) mongita.Cursor.close() CommandCursor (PyMongo docs) mongita.CommandCursor.next() mongita.CommandCursor.close() errors (PyMongo docs) mongita.errors.MongitaError (parent class of all errors) mongita.errors.PyMongoError (alias of MongitaError) mongita.errors.InvalidOperation mongita.errors.OperationFailure mongita.errors.DuplicateKeyError mongita.errors.MongitaNotImplementedError results (PyMongo docs) mongita.results.InsertOneResult mongita.results.InsertManyResult mongita.results.UpdateResult mongita.results.DeleteResult Currently implemented query operators $eq $gt $gte $in $lt $lte $ne $nin Currently implemented update operators $set $inc Contributing Mongita is an excellent project for open source contributors. There is a lot to do and it is easy to get started. In particular, the following tasks are high in priority: * More testing. Try Mongita on a project and report any bugs. The unit tests are extensive but in-the-wild bugs are always possible. * More update operators. Currently, only $set and $inc are implemented. * More query operators. Currently, only the "comparison operators" are implemented. * find_one_and_... methods. * Aggregation pipelines. * More cursor methods. Currently only sort, next, and limit are implemented. You are welcome to email me at scottmrogowski@gmail.com if you are interested. License BSD 3-clause. Mongita is free and open source for any purpose with basic restrictions related to liability, warranty, and endorsement. History Mongita was started as a component of the fastmap server. Fastmap offloads and parallelizes arbitrary Python functions on the cloud. Similar projects Both of these are similar projects which appear to be missing some important functionality (e.g. indexes). * TinyMongo * MontyDb Also worth a mention, the most popular nosql embedded database which does NOT attempt to implement the MongoDB language is UnQLite. About "Mongita is to MongoDB as SQLite is to SQL" Resources Readme License BSD-3-Clause License Releases No releases published Packages 0 No packages published Languages * Python 99.8% * Makefile 0.2% * (c) 2021 GitHub, Inc. * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.