Python library to calculate the approximate size of a firestore document
Project description
firestore_size
Python library to calculate the approximate size of a firestore document. This can be used for firebase storage cost analysis, among other things.
Installation
pip install firestore_size
Usage
from firestore_size.calculate import document_size
# initialize firebase and firestore client
collection = db.collection("data")
doc = collection.doc(id).get()
data = doc.to_dict()
doc_size = document_size(data)
print("Doc Size is ", doc_size)
How it calculates?
Checkout how the size of firestore docs is calculated in documentation.
Brief description is
- Array - The sum of the sizes of its values
- Boolean - 1 byte
- Bytes - Byte length
- Date and time - 8 bytes
- Floating-point number - 8 bytes
- Geographical point - 16 bytes
- Integer - 8 bytes
- Map - The size of the map, calculated the same way as document size
- Null - 1 byte
- Reference - The document name size
- Text string - Number of UTF-8 encoded bytes + 1
What is not included?
Does not take into account the name of a document, check docs on how it's calculated.
Does not take into account indexing. Indexes can be disabled - docs - to free up more space.
How to contribute?
Create issues for any bugs caught. Fork the repo to your account and send pull request with your changes.
Run tests using
python3 setup.py pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file firestore_size-1.0.1.tar.gz
.
File metadata
- Download URL: firestore_size-1.0.1.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf0837786fb9ea0ca6e9f2eadeff14bcf07886b1c1eaaef3ec9722f80cf5ec38 |
|
MD5 | 481b497830e992d49b1f3a11fe13158c |
|
BLAKE2b-256 | 5de7b6a7d040f1e21d86af58c34dc87d16339e753359dbbf565e2aeee4b3448f |
File details
Details for the file firestore_size-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: firestore_size-1.0.1-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cac51b0474dc9011f2f00b5ff719fce291337b695171a25d5efa1e9cd4d3247 |
|
MD5 | 1a8354b343359625025a95d1166977e2 |
|
BLAKE2b-256 | 7068f1f4ac5b4d0c094c236fb224df6e6f164ba865419ddb86462d0658b8c4fc |