Skip to main content

A simple NoSQL database greatly inspired by Firestore and Django Filters.

Project description

PyStoreDB

PyStoreDB is a simple NoSQL database greatly inspired by the Firebase Firestore, Django Filters, and LiteJsonDB. It is a JSON-based database that allows you to store and retrieve data in a simple and easy way.

Key Features

  • Simple and easy to use: PyStoreDB is designed to be simple and easy to use.
  • NoSQL database: PyStoreDB is a NoSQL database.
  • JSON-based: PyStoreDB is a JSON-based database.
  • Subcollections: PyStoreDB supports subcollections.
  • Document CRUD operations: PyStoreDB supports document CRUD operations.
  • Collection Querying operations: PyStoreDB supports collection querying operations. and where clause is inspired by Django Filters.
  • Firebase Firestore-like: PyStoreDB is greatly inspired by the Firebase Firestore.

Installation

package is not yet available on PyPI, but you can install it from the source code:

git clone https://github.com/Wilfried-Tech/PyStoreDB
cd PyStoreDB
python setup.py install

Usage

Initialize the database

from PyStoreDB import PyStoreDB
from PyStoreDB.conf import PyStoreDBSettings
from PyStoreDB.engines import PyStoreDBRawEngine

# Initialize the database
# engine_class is optional, default is PyStoreDBRawEngine
# store_dir can be '' for in-memory storage
PyStoreDB.settings = PyStoreDBSettings(store_dir="data", engine_class=PyStoreDBRawEngine)
PyStoreDB.initialize()

store = PyStoreDB.get_instance(name="my_store")  # name is optional

Create a document in a collection

# Create a document

user1 = store.collection("users").add({"name": "John Doe", "age": 25})  # auto-generate id
user2 = store.collection("users").doc().set({"name": "Jane Doe", "age": 22})  # auto-generate id
user3 = store.collection("users").doc("user3").set({"name": "Alice Doe", "age": 30})

Working with documents

# Get a document reference by id
user = store.collection("users").doc('ID')
# replace the document with a new one
user.set({"name": "John Doe", "age": 26})
# update the document
user.update({"age": 27}) or user.update(age=27)
# delete the document
user.delete()  # note that delete document does not delete subcollections

Working with collections

# Get a collection reference

users = store.collection("users")
# Get all documents in a collection
all_users = users.get()

Working with subcollections

# Get a document reference
user = store.collection("users").doc('ID')
# Get a subcollection reference
posts = user.collection("posts")
# Add a document to the subcollection
post1 = posts.add({"title": "My first post", "content": "Hello, World!"})

Querying

# Get all documents in a collection with order by age
users = store.collection("users").order_by("age").get()

# Get all documents in a collection with age greater than 25
users = store.collection("users").where(age__gt=25).get()

...

Features

  • Simple and easy to use
  • NoSQL database
  • JSON-based
  • Subcollections
  • Document CRUD operations
  • Collection Querying operations
  • Indexing
  • Transactions
  • multi-threading support
  • multi-engine support (partially implemented)

Disclaimer

This project is still in development and should not be used in production.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Feel free to contribute to this project.

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

pystoredb-0.1.0.tar.gz (29.5 kB view details)

Uploaded Source

Built Distribution

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

pystoredb-0.1.0-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

Details for the file pystoredb-0.1.0.tar.gz.

File metadata

  • Download URL: pystoredb-0.1.0.tar.gz
  • Upload date:
  • Size: 29.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for pystoredb-0.1.0.tar.gz
Algorithm Hash digest
SHA256 13b6227add1663f4a2f503747179679998c95d9e1e71945bb5b37a03b17e05db
MD5 3a9c1ae091aafbb4cd6b3f85ca7e57bb
BLAKE2b-256 0974fadf09fdd61876b6f935fd4f286ed9ce5428fbaf5e89ae1c6a9cfd6b51cc

See more details on using hashes here.

File details

Details for the file pystoredb-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pystoredb-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 31.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for pystoredb-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c1ed83853dd90130fab32e17c600fc9efacbe9bef4c05d6ed199da3313439100
MD5 1337d2693239eb11b62919119b9a8cfd
BLAKE2b-256 2e87b81fdb2f182fe1961dfa6cd80956d104ab1c039d7670903e9044a075ae4d

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