Skip to content

frankogenrwoth/pyfirebasehandler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A Python module for interacting with Firebase databases

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages