Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
easydatastore
- Create type-safe, in-memory datastorespip install easydatastore
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.
easydatastore.Table
, with a familiar pydantic-flavored syntax and ORM-like API.Column(unique=True)
Column(index=True)
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
FAQs
The easiest way to create type-safe, in-memory datastores for your models.
We found that easydatastore demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.