Metadata-Version: 2.1
Name: snailDB
Version: 0.0.2
Summary: SnailDB is a lightweight, non-SQL database for Python, designed for simplicity and ease of use
Home-page: https://github.com/cyberkutti-iedc/snailDB
Author: SREERAJ V RAJESH
Author-email: cyberkutti@gmail.com
Keywords: non-sql,database,python-database,lightwight database,non-sql database
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastjsonschema
Requires-Dist: ujson
Requires-Dist: orjson
Requires-Dist: jsonschema
Requires-Dist: pathspec
Requires-Dist: repath
Requires-Dist: typing-extensions
Requires-Dist: Flask
Requires-Dist: Flask-SocketIO


```markdown
# SnailDB

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

## Table of Contents

- [Installation](#installation)
- [Quick Start](#quick-start)
- [Features](#features)
- [Examples](#examples)
- [Contributing](#contributing)
- [License](#license)

## Installation

```bash
pip install snailDB
```

## Quick Start

```python
from snaildb import SnailDB

# Create a SnailDB instance
db = SnailDB('my_database.json')

# Insert a document
document = {'_id': 1, 'name': 'John Doe'}
db.insert(document)

# Query documents
result = db.query(lambda doc: doc['name'] == 'John Doe')
print(result)
```

## Features

### 1. **Insertion and Retrieval**
- Insert a document with `insert` method.
- Retrieve documents using `query` method.

### 2. **Query Optimization**
- **Indexing:** Implement indexing for frequently queried fields.
- **Caching:** Cache query results for frequently used queries.
- **Optimization:** Analyze and optimize query execution plans.

### 3. **Batch Operations**
- Batch insert multiple documents for improved efficiency.

### 4. **Transaction Support**
- Start, commit, and rollback transactions for atomic operations.

### 5. **Documentation and Query Optimization**
- Add comprehensive documentation for all features.
- Optimize queries and operations for better performance.

## Examples

### Examples: Inserting
```python
# Examples 1: Insert a document
document1 = {"_id": "1", "name": "Alice", "age": 30, "city": "Wonderland"}
document_id = db.insert(document1)
print(f"\nDocument ID after insertion: {document_id}")

# Examples 2: Insert a document without id
document1 = {"name": "Alice", "age": 30, "city": "Wonderland"}
document_id = db.insert(document1)
print(f"\nDocument ID after insertion: {document_id}")


# Examples 3: Insert multiple documents
documents_to_insert = [
    {"name": "Bob", "age": 25, "city": "Dreamland"},
    {"name": "Charlie", "age": 28, "city": "Fantasyville"},
]
documents_ids = db.insert_multiple(documents_to_insert)
print("\nDocument IDs after multiple insertions:", documents_ids)

```

# Examples: Get all documents in the default table
```python

all_documents = db.get_all()
print("\nAll Documents:")
print(all_documents)

# Example 4: Find documents based on a query
query = {"city": "Wonderland"}
found_documents = db.find(query)
print("\nFound Documents:")
print(found_documents)

# Example 5: Update documents based on a query
update_query = {"name": "Alice"}
update_fields = {"age": 31, "city": "Updated Wonderland"}
db.update(update_query, update_fields)
updated_document = db.find(update_query)[0]
print("\nUpdated Document:")
print(updated_document)


# Example 6: Remove documents based on a query


remove_query = {"name": "Bob"}
db.remove(remove_query)
print("\nDocuments after removal:")
print(db.get_all())

```
# Examples: Create an index for faster querying
```python
# Examples 7: Create an index for faster querying
index_fields = ["name", "city"]
db.create_index("name_city_index", index_fields)

```

# Examples: Find documents using an index
```python
# Examples 8: Find documents using an index
index_query_values = ["Alice", "Updated Wonderland"]
found_with_index = db.find_with_index("name_city_index", index_query_values)
print("\nFound with Index:")
print(found_with_index)

# Example 9: Remove an index
db.remove_index("name_city_index")

# Example 10: Remove all
db.remove_all()
print("\nDocuments after removing all:")
print(db.get_all())
```

# Query documents
```python
# Example 11: Query documents
result = db.query(lambda doc: doc['name'] == 'Alice')
print(result)


### Example 12: Indexing and Querying with Index

# Create an index for a field in a table
db.create_index('my_table', 'my_field')

# Query using the index
result = db.query_with_index('my_table', 'my_field', 'desired_value')
print(result)
```

For more examples and detailed usage, refer to the [Examples](#) document.

## Contributing

Contributions are welcome! If you'd like to contribute to SnailDB, please check the [Contributing Guide](CONTRIBUTING.md).

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
