Firebase Populator
A Python package to populate Firebase Firestore with generated data. This package helps you easily insert multiple entries into a specified Firestore collection based on a provided data template.
Installation
To install the package, use pip:
pip install firebase-populator
Requirements
Make sure to have the firebase-admin library installed, which is automatically included as a dependency.
Usage
Initialization
You need to initialize the FirebasePopulator with your Firebase service account credentials. Obtain these credentials from your Firebase project settings.
Example
Here’s how to use the FirebasePopulator class:
from firebase_populator import FirebasePopulator
# Define the path to your Firebase credentials JSON file
credential_file_path = 'path/to/your/firebase/credentials.json'
# Define the Firestore collection name
collection_name = 'your_collection'
# Define a data template for the entries to be added
data_template = {
'field1': lambda i: f'value_{i}', # Generates unique values based on the index
'field2': 'static_value', # Static value for all entries
'field3': lambda i: i * 2 # Generates values that are twice the index
}
# Initialize and populate Firestore
populator = FirebasePopulator(credential_file=credential_file_path)
populator.initialize_firebase() # Initialize Firebase
populator.populate_firestore(collection_name, data_template, num_entries=5) # Populate Firestore
Parameters
credential_file: Path to the Firebase service account key (JSON).database_url(optional): Specify if using Realtime Database.collection_name: Name of the Firestore collection to populate.data_template: A dictionary template representing the data, where values can be static or generated using a function.num_entries: Number of entries to insert into the database.
Logging
The package uses Python's logging module to log the initialization status and data insertion process. You can configure logging settings as needed.
License
This package is licensed under the MIT License.
Contributing
Contributions are welcome! Feel free to submit issues or pull requests.
Key Sections Explained:
- Installation: How to install your package using pip.
- Usage: Detailed example showing how to set up and use the
FirebasePopulatorclass, including parameter explanations. - Logging: Mentions that logging is used, providing insight into how users can monitor the process.
- License and Contributing: Standard sections for open-source projects.
Feel free to modify any parts to better match your style or additional features you may want to highlight! Let me know if you need further assistance!
Metadata
Release files for firebase-populator 0.1.2
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 |
|---|---|---|---|---|
| firebase_populator-0.1.2.tar.gz | 3.3 kB | Without provenance | Details for firebase_populator-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| firebase_populator-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for firebase_populator-0.1.2-py3-none-any.whl |
Total release size: 7.2 kB
Release files / firebase_populator-0.1.2.tar.gz
| Download URL | firebase_populator-0.1.2.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
16fa422844cdabe899235b63ee05afe2e90697539277f7ac0813ae2a7d8b6475
|
|
BLAKE2b-256 checksum How to use checksums |
87c06ddc542229ae4313270834af0751c763795a649a56f7cd342eb3b5ce28f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.5
|
Release files / firebase_populator-0.1.2-py3-none-any.whl
| Download URL | firebase_populator-0.1.2-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d664575bb201571a4044d160df2b65e1c4055a83144e1ec34da2489ab33d3a38
|
|
BLAKE2b-256 checksum How to use checksums |
5e9f80adb59a10ba21738c87e541344ebc205b8aa4e3ae149e041dd122ecc0ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.5
|
Security for firebase-populator 0.1.2
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.