Firedantic
Database models for Firestore using Pydantic base models.
Installation
The package is available on PyPi:
pip install firedantic
Usage
In your application you will need to configure the firestore db client and optionally the collection prefix, which by default is empty.
from mock import Mock
from os import environ
import google.auth.credentials
from firedantic import configure
from google.cloud import firestore
# Firestore emulator must be running if using locally.
if environ.get("FIRESTORE_EMULATOR_HOST"):
client = firestore.Client(
project="firedantic-test",
credentials=Mock(spec=google.auth.credentials.Credentials)
)
else:
client = firestore.Client()
configure(client, prefix="firedantic-test-")
Once that is done, you can start defining your Pydantic models, e.g:
from pydantic import BaseModel
from firedantic import Model
class Owner(BaseModel):
"""Dummy owner Pydantic model."""
first_name: str
last_name: str
class Company(Model):
"""Dummy company Firedantic model."""
__collection__ = "companies"
company_id: str
owner: Owner
# Now you can use the model to save it to Firestore
owner = Owner(first_name="John", last_name="Doe")
company = Company(company_id="1234567-8", owner=owner)
company.save()
# Prints out the firestore ID of the Company model
print(company.id)
License
This code is released under the BSD 3-Clause license. Details in the LICENSE file.
Metadata
Release files for firedantic 0.1.3
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 |
|---|---|---|---|---|
| firedantic-0.1.3.tar.gz | 5.5 kB | Without provenance | Details for firedantic-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| firedantic-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for firedantic-0.1.3-py3-none-any.whl |
Total release size: 12.4 kB
Release files / firedantic-0.1.3.tar.gz
| Download URL | firedantic-0.1.3.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
757ac155401b05d174d6754c45dc4afe7052dd5ef6d508f24a8b2cadf7b0fd17
|
|
BLAKE2b-256 checksum How to use checksums |
19a2fda4d78f682e6faa85dd87a93a2b024aa140de5f58be8c4615c2eea2ca26
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/3.6.7 Linux/4.15.0-1077-gcp
|
Release files / firedantic-0.1.3-py3-none-any.whl
| Download URL | firedantic-0.1.3-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
daa06a3ffd5a3cfc3f635d85930dfa83abe694f6be51b8fb16c4a441e79bc48c
|
|
BLAKE2b-256 checksum How to use checksums |
e367c4cc46f561bf30461108ed11d4f085d7a0bae369388a38e521edae506cd4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/3.6.7 Linux/4.15.0-1077-gcp
|
Security for firedantic 0.1.3
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.