Skip to main content

SnailDB, a lightweight, non-SQL database for Python.

Project description

Certainly! Below is an enhanced version of your README.md for SnailDB:

# SnailDB

SnailDB is a lightweight, non-SQL database for Python, designed for simplicity and ease of use.

## Table of Contents

- [Installation](#installation)
- [Version](#version)
- [Quick Start](#quick-start)
- [Examples](#examples)
- [Delete](#delete)
- [Query](#query)
- [Features](#features)
- [Contributing](#contributing)
- [License](#license)

## Installation

```bash
pip install snailDB

Version

from snaildb import version

# To check which version of SnailDB is installed
print(version())

Quick Start

from snaildb import SnailDB

# Create a SnailDB instance
db = SnailDB("database.json", "data")

# Get the name of the database
print("Using database:", db.get_db_name())

# Insert data
db.insert({"key": "1", "name": "John", "age": 30})
db.insert({"key": "2", "name": "Alice", "age": 25})

# Get data
print("Key '1' data:", db.get("1"))

Examples

# Setup the database on db
db = SnailDB("my_database.json", "data")

# Example 1: Insert a document using insert() function
db.insert({"key": "1", "name": "Akhil", "age": 20})

# Example 2: Insert multiple documents using insert_all() function
db.insert_all({"key": "3", "name": "Jon", "age": 10}, {"key": "4", "name": "Ali", "age": 21})
# Example 3: Update the database
# For updating the database, use the key value.
db.update("1", {"name": "John", "age": 31})

# Example 4: View the database
# Print data without pretty formatting:
print(db.get("1"))

# Print data with pretty formatting:
print(db.get("1", pretty=True))
# Example 5: View all the database
# Print all data without pretty formatting:
print(db.get_all())

# Print all data with pretty formatting:
print(db.get_all(pretty=True))

Delete

# Example 6: Delete data
# For deleting data, enter the key
db.delete("2")

# Example 7: Delete the entire database
# The db database will be deleted
db.drop()

Query

# Query Function without pretty formatting
test = db.query("age", "<", 30)
print(test)

# Query Function with pretty formatting
test = db.query("age", "<", 30, pretty=True)
print(test)

# We can use all operators

#Greater Operator

test = db.query("age", ">", 30, pretty=True)
print(test)

#Lesser Operator
test = db.query("age", "<", 30, pretty=True)
print(test)

#Equal to operator
test = db.query("name", "=", "Ali", pretty=True)
print(test)

# Lesser and Equal to operator
test = db.query("age", "<=", 29, pretty=True)
print(test)

# Greater and Equal to operator
test = db.query("age", ">=", 29, pretty=True)
print(test)

# Not Equal to operator
test = db.query("age", "!=", 29, pretty=True)
print(test)

# Query Method with Skip Method
test = db.query("age", "<", 30, skip=1, pretty=True)
print(test)

# Query Method with Limt method
test = db.query("age", "<", 30, limt=1, pretty=True)
print(test)

# Query Method with Limt method and skip method
test = db.query("age", "<", 30, skip=1, limt=1, pretty=True)
print(test)

Features

  • Lightweight: SnailDB is designed to be a lightweight database, providing basic functionalities without unnecessary complexities.
  • Simple API: The API is easy to use, making it suitable for small to medium-sized projects.
  • Persistent Storage: Data is stored in a JSON file, ensuring persistence across sessions.
  • Basic CRUD Operations: SnailDB supports basic Create, Read, Update, and Delete operations.
  • Query Functionality: Perform simple queries based on field name, operator, and target value.

Contributing

Contributions are welcome! If you'd like to contribute to SnailDB, please check the Contributing Guide.

License

This project is licensed under the MIT License. See the LICENSE file for 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

snailDB-0.0.3.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

snailDB-0.0.3-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file snailDB-0.0.3.tar.gz.

File metadata

  • Download URL: snailDB-0.0.3.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.4

File hashes

Hashes for snailDB-0.0.3.tar.gz
Algorithm Hash digest
SHA256 8bc3d88a132eab8a1ed801df38524c03f9897e7bc20628513b1be1bf319bf1dc
MD5 c877ec6bd35cb93f8c5c7cb337a3beb0
BLAKE2b-256 1fb5262b735a919ccb72338ae4003382059e701cd2cf577d253ac58a70c4faff

See more details on using hashes here.

File details

Details for the file snailDB-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: snailDB-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.4

File hashes

Hashes for snailDB-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5f445389f71936a18cef9ea5517413b77b48384368eb49e8599f2efd8114f014
MD5 f48b3421c6046e2d7e0627f2bf97cfd1
BLAKE2b-256 a3b14af24f270ae2955e28521fee9569d32f5815d0fa78b5bf8844352d1c966f

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