Skip to main content

A Firestore-like wrapper for SQL databases.

Project description

FireWrap

FireWrap is a Python library that provides a Firebase Firestore-like interface for SQLite databases. It allows you to perform CRUD operations on collections and documents, making it easier to work with SQLite in a way that resembles Firebase Firestore.

Features

  • Encode and decode column names for SQLite compatibility.
  • Migrate data from Firebase to SQLite.
  • Perform CRUD operations on collections and documents.
  • Support for JSON data storage and retrieval.

Installation

To install FireWrap, install the module:

pip install FireWrap

Usage

Initialize FireWrap

To use FireWrap, you need to create an instance of the FireWrap class, specifying the database path:

from firewrap import FireWrap

db = FireWrap('path/to/your/database.db')

Working with Collections

You can get a reference to a collection and perform operations like adding documents, retrieving documents, and counting documents.

Add a Document

data = {"name": "John Doe", "age": 30}
doc = db.collection("users").addDoc(data)

Get All Documents

docs = db.collection("users").getDocs()

Get a Document by ID

doc = db.collection("users").doc("document_id").getDoc()

Update a Document

update_data = {"age": 31}
db.collection("users").doc("document_id").updateDoc(update_data)

Delete a Document

db.collection("users").doc("document_id").deleteDoc()

API Endpoints

FireWrap also provides a Flask-based API for interacting with the database over HTTP.

  • GET /collections/: Retrieve all documents in a collection.
  • POST /collections/: Add a new document to a collection.
  • GET /collections//<doc_id>: Retrieve a specific document by ID.
  • POST /collections//<doc_id>: Create a new document with a specific ID.
  • PATCH /collections//<doc_id>: Update a specific document.
  • DELETE /collections//<doc_id>: Delete a specific document.
  • GET /collections//count: Get the total number of documents in a collection.

Migration from Firebase

To migrate data from Firebase to FireWrap, use the migrate_firebase_to_firesql function:

from port import migrate_firebase_to_firesql

migrate_firebase_to_firesql('path/to/firebase/credentials.json', 'firesql.db')

License

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

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

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

firewrap-0.1.3.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

FireWrap-0.1.3-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file firewrap-0.1.3.tar.gz.

File metadata

  • Download URL: firewrap-0.1.3.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for firewrap-0.1.3.tar.gz
Algorithm Hash digest
SHA256 347fce88de739764e1207f042d6827c76e9bb9151cb2d12333152b79f8d42640
MD5 1f1247757af340077902c82540b32edd
BLAKE2b-256 12974dcbec82edd470c0ada94e6266a76172e5b5f10a0d3c1c466f6ed4f648cf

See more details on using hashes here.

File details

Details for the file FireWrap-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: FireWrap-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for FireWrap-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2a18ae83c99e7cd88719e7e9dca79ced0f1c786fb47114a5097ada33908f1adb
MD5 f8949a116b3a8daf6f9cc4bda6fceca5
BLAKE2b-256 e642524bd20c94a67f05e9607a40a0df6092104cab9349749c7879ee8851c2b6

See more details on using hashes here.

Supported by

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