Scruby-Json
Plugin for Scruby - In search methods, returns result as json strings.
Scruby-Json is a plugin for the Scruby project.
Installation
uv add scruby-json
Usage
import anyio
from typing import Any
from pydantic import Field
from scruby import Scruby, ScrubyModel, ScrubyConfig
from scruby_json import ReturnJson
# Plugins connection.
ScrubyConfig.plugins = [
ReturnJson,
]
class Car(ScrubyModel):
"""Car model."""
brand: str = Field(strict=True, frozen=True)
model: str = Field(strict=True, frozen=True)
year: int = Field(strict=True, frozen=True)
power_reserve: int = Field(strict=True, frozen=True)
description: str = Field(strict=True)
# key is always at bottom
key: str = Field(
strict=True,
frozen=True,
default_factory=lambda data: f"{data['brand']}:{data['model']}",
)
async def main() -> None:
"""Example."""
# Get collection `Car`
car_coll = await Scruby.collection(Car)
# Create cars.
for num in range(1, 10):
car = Car(
brand="Mazda",
model=f"EZ-6 {num}",
year=2025,
power_reserve=600,
description="Electric cars are the future of the global automotive industry.",
)
await car_coll.add_doc(car)
# Find one car
car_json: str | None = await car_coll.plugins.returnJson.find_one(
filter_fn=lambda doc: doc.brand == "Mazda" and doc.model == "EZ-6 9",
)
if car_json is not None:
print(car_json)
else:
print("Not Found")
# Fand many cars
car_json_list: list[str] | None = await car_coll.plugins.returnJson.find_many(
filter_fn=lambda doc: doc.brand == "Mazda",
)
if car_json_list is not None:
print(car_json_list)
else:
print("Not Found")
# Full database deletion.
# Hint: The main purpose is tests.
Scruby.napalm()
if __name__ == "__main__":
anyio.run(main)
Metadata
Release files for scruby-json 0.6.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| scruby_json-0.6.4-py3-none-any.whl | Python 3 | none | any | Details for scruby_json-0.6.4-py3-none-any.whl |
Release files / scruby_json-0.6.4-py3-none-any.whl
| Download URL | scruby_json-0.6.4-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
29c047d2c708af20490f9be9e8695c61a45230a95d9f5c4e341c99f0f1f14554
|
|
BLAKE2b-256 checksum How to use checksums |
8a7f3c3c66ae59621432e50354d53f2f04dd49c10a5146b5ee25d976e5655420
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for scruby-json 0.6.4
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.