Skip to main content

A custom wrapper for Google Firestore.

Project description

firestore-wrapper

firestore-wrapper is a custom Python wrapper designed to simplify and streamline operations with Google Firestore. By abstracting the complexities of direct Firestore interaction, it provides an easier and more Pythonic way to work with Firestore databases, including document management, querying, and batch operations.

Features

  • Simplified document addition, update, and retrieval
  • Batch operations support
  • Automated backup and restoration capabilities
  • Customizable query methods

Installation

Install firestore-wrapper using pip:

pip install firestore-wrapper

Ensure you have a Google Cloud project with Firestore enabled and service account credentials available.

Quick Start

First, set up your Firestore credentials:

  1. Go to the Google Cloud Console.
  2. Navigate to IAM & Admin > Service Accounts.
  3. Create a service account and download the JSON credentials file.

Next, initialize FirestoreDB with your credentials:

from firestore_wrapper import FirestoreDB

# Path to your Firestore credentials JSON file
credentials_path = 'path/to/your/credentials.json'
database_url = 'your-database-url'  # Optional, if using a custom Firestore database

# Initialize the FirestoreDB instance
db = FirestoreDB(credentials_path=credentials_path, database=database_url)

Adding a Document

# Define your document data
data = {
    'name': 'John Doe',
    'email': 'john.doe@example.com',
    'signup_date': '2023-01-01'
}

# Add a document to the 'users' collection
document_name = db.add_document(collection_name='users', data=data, document_name='user_johndoe')
print(f'Document added with name: {document_name}')

Retrieving a Document

# Retrieve a document by name
user_document = db.get_document_data(collection_name='users', document_name='user_johndoe')
print(user_document)

Updating a Document

# Update a document with new data
update_data = {'email': 'new.email@example.com'}
db.update_document(collection_name='users', document_name='user_johndoe', data=update_data)

Getting Help

If you encounter any issues or have questions about using firestore-wrapper, please create an issue in the GitHub repository.

Contributing

Contributions to firestore-wrapper are welcome! Whether it's bug reports, feature requests, or code contributions, please feel free to make a contribution. For code contributions, please:

  1. Fork the repository.
  2. Create a new branch for your feature or fix.
  3. Submit a pull request.

Please ensure your code adheres to the project's coding standards and includes appropriate tests.

License

firestore-wrapper is released under the MIT License. See the LICENSE file for more details.

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

firestore_wrapper-0.1.1.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

firestore_wrapper-0.1.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file firestore_wrapper-0.1.1.tar.gz.

File metadata

  • Download URL: firestore_wrapper-0.1.1.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.8

File hashes

Hashes for firestore_wrapper-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c864a1e8bc7ec329ab354934d4128b3e4122773f78349d0953b769ce4e419bda
MD5 3f44a5c29d0c0f4d2d4772889b96d483
BLAKE2b-256 ec43113d5d4c213691b7101e3ebe7f30a6ebe7d8ef3021c89d0b8e6ee5920281

See more details on using hashes here.

Provenance

File details

Details for the file firestore_wrapper-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for firestore_wrapper-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1e30c244c19bd1ccdfd01b8f95a0178797e43b4195d67fc4190415ba1bad0664
MD5 84f288e4028073c7ae39da4b7c9fbcaa
BLAKE2b-256 8eba53a2e844dba20e079fb7f27a56babfcfc45977a58083129100c6d6fabdf5

See more details on using hashes here.

Provenance

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