============
A Fast Embedded Database in Python.
------------------------------------
Use case: You want to prototype an idea wihtout a heavyweight database install. If the idea works out though, you don't want
to rewrite all of your data access code.
EssentialDB helps solve that problem by being (nearly) api compatible with MongoDB. That way when your idea starts to grow,
you can switch to MongoDB to scale.
* Syntax and semantics are very similar to MongoDB, lowering the barrier of entry.
* Fairly complex query support.
* Its in pure python.
* Its very fast.
`Project On GitHub <https://github.com/shane-mason/essentialdb>`_ |
`Full Docs @ ReadTheDocs <http://essentialdb.readthedocs.io/en/latest/>`_ |
`Distribution On Pypi <https://pypi.python.org/pypi/essentialdb>`_
|Build Status| |Coverage| |Version|
Current Status
---------------
Just getting started!
Quickstart
-----------
Install with pip::
pip install essentialdb
Basic usage is straightforward::
from essentialdb import EssentialDB
#create or open the database
author_db = EssentialDB(filepath="authors.db")
#insert a document into the database
author_db.insert_one({'first': 'Langston', 'last': 'Hughes', 'born': 1902});
#find some entries
results = author_db.find({'last':'Hughes'})
#commit the changes to disk
author_db.sync()
Or using the 'with' semantics to assure that write happen without having to explicitly call sync::
with EssentialDB(filepath="authors.db") as author_db:
author_db.insert_one({'first': 'Langston', 'last': 'Hughes', 'born': 1902});
Insert a document::
author = {'first': 'Langston', 'last': 'Hughes', 'born': 1902}
author_db.insert_one(author)
Insert many documents::
authors = [{'first': 'Langston', 'last': 'Hughes', 'born': 1902},
{'first': 'Ezra', 'last': 'Pound', 'born': 1885}]
author_db.insert_many(authors)
Find one document::
document = author_db.find_one({'first': 'Ezra', 'last': 'Pound'})
Find many::
documents = author_db.find({'born': {'$gt': 1900}})
Update one::
updated = author_db.update({'_id': {'$eq': "A345i"}}, {'born': 1902})
Update many::
updated = author_db.update({'born': {'$gt': 1900}}, {'period': 'Modern'})
Remove Items::
removed = author_db.remove({'period':'Modern'))
Nested Queries::
customer_db.insert_one({'first': 'John', 'last': 'Smith', 'address': { 'street': '10 Maple St', 'city': 'Missoula', 'state': 'MT'}})
results = customer_db.find({'address.state':'MT'})
Note that nested query support means that key names can not include a period.
Write updates to disk::
author_db.sync()
Queries
--------
Queries in EssentialDB follow the same basic form as MongoDB::
{ <field1>: { <operator1>: <value1> }, ... }
Comparison Query Selectors
^^^^^^^^^^^^^^^^^^^^^^^^^^^
The $eq operator matches documents where the value of a field equals the specified value::
author_db.find({"born" : {"$eq": 1972}})
The $ne operator matches documents where the value of a field is not equal to the specified value::
author_db.find({"born" : {"$ne": 1972}})
The $gt operator matches documents where the value of a field is greater than the specified value::
author_db.find({"born" : {"$gt": 1900}})
The $gte operator matches documents where the value of a field is great than or equal to the specified value::
author_db.find({"born" : {"$gte": 1900}})
The $lt operator matches documents where the value of a field is less than the specified value::
author_db.find({"born" : {"$lt": 1900}})
The $lte operator matches documents where the value of a field is less than or equal to the specified value::
author_db.find({"born" : {"$lte": 1900}})
The $in operator matches documents where the value of a field is equal any item in the specified array::
author_db.find({"genre" : {"$in": ["tragedy", "drama"]}})
The $nin operator matches documents where the value of a field is not equal to any item in the specified array::
author_db.find({"genre" : {"$nin": ["tragedy", "drama"]}})
Boolean Operators
^^^^^^^^^^^^^^^^^
The $and operator matches documents where all the fields match::
#find authors born after 1900 and before 2000
author_db.find({'$and':[{'born': {'$gte': 1900}},{'born': {'$lt': 2000}}]})
The $or operator matches documents where any of the fields match::
#find authors with either the first or last name John
author_db.find({'$or':[{'first': {'$eg': 'John'}},{'last': {'$eq': 'John'}}]})
The $nor operator matches document where none of the conditions match::
#find all authors who have neither the first or last name John
author_db.find({"$nor":[{'first': {"$eq": 'John'}},{'last': {'$eq': 'John'}}]})
Metadata
Release files for essentialdb 0.3.19
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| essentialdb-0.3.19.zip | 16.0 kB | Without provenance | Details for essentialdb-0.3.19.zip |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| essentialdb-0.3.19-py3-none-any.whl | Python 3 | none | any | Details for essentialdb-0.3.19-py3-none-any.whl |
Total release size: 28.4 kB
Release files / essentialdb-0.3.19.zip
| Download URL | essentialdb-0.3.19.zip |
|---|---|
| Size | 16.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2ea20871cfe29bfd04ecef026aa7d9a1ec4639295adc2adf5836da1390124b14
|
|
BLAKE2b-256 checksum How to use checksums |
8498df7141c4ac4b6d7d26a76505cd8dd763fe2a3167128188f305b523c67296
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / essentialdb-0.3.19-py3-none-any.whl
| Download URL | essentialdb-0.3.19-py3-none-any.whl |
|---|---|
| Size | 12.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
61144d8d9982bc421a90bb4df1effa18bafc4ba4702cf890dcd6f614acd75647
|
|
BLAKE2b-256 checksum How to use checksums |
ca1ef06f1bb2d878eb2c17422dd3668e33553d7f0ce8b4f5458a0c8935536667
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for essentialdb 0.3.19
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.