Metadata-Version: 2.1
Name: hidb
Version: 0.0.2
Summary: It is a file based key value data store 
Home-page: https://github.com/sk-ip/hidb
Author: Sudhanshu Kumar
Author-email: sudhanshukumar5459@gmail.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown

# hidb :wave:

[![Python package](https://github.com/sk-ip/hidb/workflows/Python%20package/badge.svg)](https://github.com/sk-ip/hidb/actions)
[![Upload Python Package](https://github.com/sk-ip/hidb/workflows/Upload%20Python%20Package/badge.svg)](https://github.com/hidb/actions)
[![PyPI version](https://img.shields.io/pypi/v/hidb.svg)](https://pypi.org/project/hidb)

hidb is a file based key-value data store

## Installation
```console
$ pip install hidb
```

## Usage
hidb can be used as a python package for saving JSON object data in the local storage.

### Initialize
Initialize the database with the location you want to store the data, here we are using the current directory
```python
from hidb import fileStoreDB

db = fileStoreDB("./")
```

### Add the data
create method takes three values
* __key__ It is the unique key to recognise the data
* __data__ It is the JSON object to store
* __ttl__ It is an integer, the number of seconds the data should be available in the database, if left blank the data would persist indefinitely.
```python
data = '{"name": "John Doe", "age": 20, "hobby": ["Reading", "Coding","Travelling"]}'
db.create("mydata", data, 20)
```

### Read from the database
To read from the database, simply provide the key
```python
print(db.read("mydata"))
```

### Delete the record from the database
To delete from the database, simply provide the key
```python
db.delete("mydata")
```

### To save the database on the local storage
Provide the name with which to save the file
```python
db.saveData("mydata.pk")
```

### To load from an existing database
To load from an existing file, first we need to create the database instance and then load the data into it.
```python
db = fileStoreDB("./")
db.loadData("mydata.pk")
```


