No project description provided
Project description
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
FirebasePopulator
class, 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!
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 firebase_populator-0.1.2.tar.gz
.
File metadata
- Download URL: firebase_populator-0.1.2.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16fa422844cdabe899235b63ee05afe2e90697539277f7ac0813ae2a7d8b6475 |
|
MD5 | 99c43c423701b9400a832bb4244674f7 |
|
BLAKE2b-256 | 87c06ddc542229ae4313270834af0751c763795a649a56f7cd342eb3b5ce28f8 |
File details
Details for the file firebase_populator-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: firebase_populator-0.1.2-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d664575bb201571a4044d160df2b65e1c4055a83144e1ec34da2489ab33d3a38 |
|
MD5 | 813a21c9e2a9f03db90d59bbe186a14b |
|
BLAKE2b-256 | 5e9f80adb59a10ba21738c87e541344ebc205b8aa4e3ae149e041dd122ecc0ab |