easydatastore - Create type-safe, in-memory datastores
Requirements
- Python 3.11+
Install
pip install easydatastore
Usage
If you want to prototype a web application quickly and just need a way to validate your mock data, you can use easydatastore to create an in-memory datastore for your models, directly out of the box.
Features:
- In-memory tables for your models with
easydatastore.Table, with a familiar pydantic-flavored syntax and ORM-like API. - Enforce uniqueness constraints with
Column(unique=True) - Use indexing for faster lookups with
Column(index=True) - IDE-friendly type hints ensure your coding experience is type-safe.
Example
import easydatastore.exceptions
from easydatastore import Column, Table
class Person(Table):
name: str = Column(primary_key=True)
email: str | None = Column(unique=True, default=None)
family_name: str
age: int
Person(name="Snap", family_name="Krispies", email="snap@example.com", age=92)
Person(name="Crackle", family_name="Krispies", age=92)
Person(name="Pop", family_name="Krispies", age=92)
Person(name="Tony", family_name="Tiger", email="tony@example.com", age=72)
Person(name="Cap'n", family_name="Crunch", age=53)
# retrieve an instance from the table using the .get() method and a primary key value
tony = Person.get("Tony")
print(tony) # Person(name='Tony', email=None, family_name='Tiger')
# or query your table using the .filter() method
print([person.name for person in Person.filter(family_name="Krispies")]) # ["Snap", "Crackle", "Pop"]
print([person.name for person in Person.filter(lambda person: person.age < 90)]) # ["Tony", "Cap'n"]
# delete instances from the table with the .delete() method
Person.delete(Person.get("Crackle"))
print([person.name for person in Person.all()]) # ["Snap", "Pop", "Tony"]
# easydatastore will validate uniqueness for you... these operations will raise exceptions:
try:
tony.email = Person.get("Snap").email
except ValueError as e:
print(e.args[0]) # ValueError: Value 'snap@example.com' for field 'email' is not unique
try:
Person(name="Snap", family_name="Rice", age=1)
except easydatastore.exceptions.DuplicateUniqueFieldValueError as e:
print(e.args[0]) # DuplicateUniqueFieldValueError
Metadata
Release files for easydatastore 0.1.7
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 |
|---|---|---|---|---|
| easydatastore-0.1.7.tar.gz | 8.9 kB | Without provenance | Details for easydatastore-0.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| easydatastore-0.1.7-py3-none-any.whl | Python 3 | none | any | Details for easydatastore-0.1.7-py3-none-any.whl |
Total release size: 20.5 kB
Release files / easydatastore-0.1.7.tar.gz
| Download URL | easydatastore-0.1.7.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6aeaa59eab51b222fea3ac2c0a9f96c0161cf65bf3ec287ad99fea16794eeacd
|
|
BLAKE2b-256 checksum How to use checksums |
f3bdf9ed375dfd99c92e7e2e703a813f3c74b634d2d16244ff06f9204677d57a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.1 Darwin/23.5.0
|
Release files / easydatastore-0.1.7-py3-none-any.whl
| Download URL | easydatastore-0.1.7-py3-none-any.whl |
|---|---|
| Size | 11.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
72720bf0d661b8150df05676d40b34cad24223463eb02b2d59b5037a863ba348
|
|
BLAKE2b-256 checksum How to use checksums |
db87c41654b2974d2e29257cc6dea0616ec64cc9cea27ace92ce90343c7009de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.1 Darwin/23.5.0
|
Security for easydatastore 0.1.7
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.