Skip to main content

Simple in-memory CRUD store for rapid prototyping

Project description

crudtape

Like ducktape but for CRUD...

A lightweight in-memory CRUD store for Pydantic-style objects, designed for rapid prototyping with frameworks like FastAPI and Flask.

Installation

pip install crudtape

Usage

The store is designed to work with any model class that implements the basic Storable protocol, which defines a minimal subset of the Pydantic model interface. Importantly, the store does not depend on Pydantic itself - you can use any compatible class. This means:

  • Pydantic models (as-is)
  • @dataclass decorated classes
  • Custom classes built from scratch

The only caveat is that the store manages the object IDs internally. In essence, a compatible model class needs to provide:

  • __init__ method that accepts keyword arguments, including an optional id of type int (used when constructing returned objects).
  • model_dump() method returning a dictionary representation, excluding the id attribute (it will be ignored by the store otherwise).
import BaseModel from pydantic

class Pet(BaseModel):
    name: str
    age: str
    id: int = None

Additional examples are shown in the test suit.

The class is used to create a corresponding store instance:

import Store from crudtape

store = Store(Pet)

The store offers basic self-explanatory CRUD operations, all typed to the specified model class and with decent error checking. See the API reference for full details.

# insert an object
store.insert(Pet(name="Bob", age=3))

# list all objects 
store.all()

# get an object with given ID
store.get(1)

# update an object with given ID
store.update(1, Pet(name="Rob", age=5))

# delete an object with given ID
store.delete(1)

The store raises StoreError for general failures, with two exceptions: NotFoundError is raised when an object with the given ID doesn’t exist, and TypeError when an input object has the wrong type.

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

crudtape-0.1.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crudtape-0.1.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file crudtape-0.1.0.tar.gz.

File metadata

  • Download URL: crudtape-0.1.0.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for crudtape-0.1.0.tar.gz
Algorithm Hash digest
SHA256 694ae2aa7050044dc6edf41b84709bcf7458e085e2615fd17cd12883e2519605
MD5 ff220f0a2ba04efaeb319c4ad2993aa0
BLAKE2b-256 eeb320458fcf314dc3c2d9157a452cbf0e044a049c47e209ac85388d5bcb910a

See more details on using hashes here.

Provenance

The following attestation bundles were made for crudtape-0.1.0.tar.gz:

Publisher: publish.yaml on alesbukovsky/crudtape

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file crudtape-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: crudtape-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for crudtape-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe48ea3c0b4ede840bd282e70d37039f9ecb1e8087e9a63e6c47d1cd45682c7d
MD5 40fd2a9f7549667e6ca14f6d82d6eb23
BLAKE2b-256 3db0f40b44610db9558ff2f46a56340cd1611e1e3564b96720488be482ad50f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for crudtape-0.1.0-py3-none-any.whl:

Publisher: publish.yaml on alesbukovsky/crudtape

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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