Skip to main content

A Python module for handling a Firebase database

Project description

Certainly! Here's an example README.md file for your module:

# pyfirebasehandler

[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)

Your Module is a Python module for handling a Firebase database using the `firebase-admin` library.

## Installation

You can install Your Module using pip:

```shell
pip install pyfirebasehandler

Make sure you have the firebase-admin library installed as well.

Usage

from pyfirebasehandler.firebase_handler import FirebaseHandler

# Initialize FirebaseHandler with credentials
handler = FirebaseHandler('path/to/credentials.json')

# Create a document
data = {'name': 'John Doe', 'age': 30}
document_id = handler.create_document('users', data)

## for creating a document with a custom reference
document_id = handler.create_document('users', data, custom_ref="id01")
print(f"Created document with ID: {document_id}")

# Retrieve a document
document_data = handler.get_document('users', document_id)
print(f"Retrieved document data: {document_data}")

# Retrive list of documents from a collection
collection_data = handler.read_collection('users')
print(f"Retrieved list of collection data: {document_data}")

# Update a document
updated_data = {'age': 31}
handler.update_document('users', document_id, updated_data)
print("Document updated successfully")

# Delete a document
handler.delete_document('users', document_id)
print("Document deleted successfully")

Replace 'path/to/credentials.json' with the actual path to your Firebase service account credentials JSON file.

Tests

To run the tests for Module, execute the following command:

python -m unittest tests.test_firebase_handler

Make sure you have the necessary test credentials for your Firebase database.

License

This project is licensed under the terms of the MIT License. See the LICENSE file for details.

MIT License

Copyright (c) 2023 pyfirebasehandler

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyfirebasehandler-1.0.0.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

pyfirebasehandler-1.0.0-py3-none-any.whl (5.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page