semvec/pypi-packages huggingface dataset:
hidb 0.0.2
It is a file based key value data store
Requires Python: >=3.6

# 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")
```