Skip to content

Commit

Permalink
readme updates, v0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabh0719 committed May 12, 2021
1 parent 108dc64 commit 81a3b49
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 47 deletions.
38 changes: 21 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div align="center">
<img src="elara.png" width ="75%">
<p>Elara DB is an easy to use, key-value database written for python that can also be used as a fast in-memory cache. Includes various methods to manipulate data structures in-memory, secure database files and export data.</p>
<p>Elara DB is an easy to use, lightweight NoSQL database written for python that can also be used as a fast in-memory cache. Includes various methods to manipulate data structures in-memory, secure database files and export data.</p>
</div>

```sh
Expand Down Expand Up @@ -86,11 +86,11 @@ print(db.get("name"))

```

* `exe_secure(db_file_path, commit=False, key_file_path)` - Loads the contents of the encrypted database (using the key file) into the program memory or generates a new key file and/or database file if they don't exist in the given path and it encrypts/decrypts the database file. Data is encoded into a *base64* format and then encrypted using *Fernet encryption*
* `exe_secure(db_file_path, commit=False, key_file_path)` - Loads the contents of the encrypted database (using the key file) into the program memory or generates a new key file and/or database file if they don't exist in the given path and it encrypts/decrypts the database file. Data is encoded into a `base64` format and then encrypted using `Fernet encryption`

Using `exe_secure()` without a key file or without the correct key file corresponding to the database will result in errors. Key files and DB files can be included inside the *.gitignore* to ensure they're not pushed into an upstream repository.
Using `exe_secure()` without a key file or without the correct key file corresponding to the database will result in errors. Key files and DB files can be included inside the `.gitignore` to ensure they're not pushed into an upstream repository.

* *`commit`* - this argument defaults to *`False`* ie. you will have to manually call the `commit()` method to write the in-memory changes into the database. If set to *`True`*, changes will be written into the file after every operation.
* `commit` - this argument defaults to `False` ie. you will have to manually call the `commit()` method to write the in-memory changes into the database. If set to `True`, changes will be written into the file after every operation.

```python
import elara
Expand Down Expand Up @@ -121,16 +121,18 @@ print(db.get("name"))

All the following operations are methods that can be applied to the instance returned from `exe()` or `exe_secure()`. These operations manipulate/analyse data in-memory after the Data is loaded from the file. Set the `commit` argument to `True` else manually use the `commit()` method to sync in-memory data with the database file.

* `get(key)` - returns the corresponding value from the db or *`None`*
* `set(key, value)` - returns *`True`* or an Exception. The `key` has to be a String.
* `get(key)` - returns the corresponding value from the db or `None`
* `set(key, value)` - returns `True` or an Exception. The `key` has to be a String.
* `rem(key)` - deletes the key-value pair if it exists.
* `incr(key, val=1)` - increments the value (has to be an `int` or a `float`) present at the given key with the `val` parameter (default `1`, `int` or a `float`). For float operations it rounds the result to 3 decimal points.
* `decr(key, val=1)` - decrements the value (has to be an `int` or a `float`) present at the given key with the `val` parameter (default `1`, `int` or a `float`). For float operations it rounds the result to 3 decimal points.
* `clear()` - clears the database data currently stored in-memory.
* `exists(key)` - returns *`True`* if the key exists.
* `exists(key)` - returns `True` if the key exists.
* `commit()` - write in-memory changes into the database file.
* `getset(key, value)` - Sets the new value and returns the old value for that key or returns *`False`*.
* `getkeys()` - returns the list of keys in the database with. The list is ordered with the *`least recently accessed`* keys starting from index 0.
* `getset(key, value)` - Sets the new value and returns the old value for that key or returns `False`.
* `getkeys()` - returns the list of keys in the database with. The list is ordered with the `least recently accessed` keys starting from index 0.
* `numkeys()` - returns the number of keys in the database.
* `retkey()` - returns the Key used to encrypt/decrypt the db file; returns *`None`* if the file is unprotected.
* `retkey()` - returns the Key used to encrypt/decrypt the db file; returns `None` if the file is unprotected.
* `retmem()` - returns all the in-memory db contents.
* `retdb()` - returns all the db file contents.

Expand All @@ -154,14 +156,16 @@ print(db.retdb())

```

Note - `retmem()` and `retdb()` will return the same value if *`commit`* is set to *`True`* or if the `commit()` method is used before calling `retdb()`
Note - `retmem()` and `retdb()` will return the same value if `commit` is set to `True` or if the `commit()` method is used before calling `retdb()`

<span id="cache"></span>
### Cache:

Elara can also be used as a fast in-memory cache. Start/open a new instance and ensure the `commit` argument is *`False`* or left empty (`commit` defaults to `False`), to prevent writes into the database file.
Elara can also be used as a fast in-memory cache. Start/open a new instance and ensure the `commit` argument is `False` or left empty (`commit` defaults to `False`), to prevent writes into the database file.

* `cull(percentage)` - `percentage` (0 <= percentage <= 100) defines the percentage of Key-Value pairs to be deleted, with the *Least recently accessed* keys being deleted first. Elara maintains a simple LRU list to track key access.
* `cull(percentage)` - `percentage` (0 <= percentage <= 100) defines the percentage of Key-Value pairs to be deleted, with the `Least recently accessed` keys being deleted first. Elara maintains a simple LRU cache to track key access.

Further updates coming soon for caching.

```python
import elara
Expand Down Expand Up @@ -203,10 +207,10 @@ print(cache.getkeys())

* `mget(keys)` - takes a list of keys as an argument and returns a list with all the corresponding values IF they exist; returns an empty list otherwise.
* `mset(dict)` - takes a dictionary of key-value pairs as an argument and calls the `set(key, value)` method for each pair. Keys have to be a String.
* `setnx(key, value)` - Sets the key-value if the key does not exist and returns *`True`*; returns *`False`* otherwise.
* `setnx(key, value)` - Sets the key-value if the key does not exist and returns `True`; returns `False` otherwise.
* `msetnx(dict)` - takes a dictionary of key-value pairs as an argument and calls the `setnx(key, value)` method for each pair. Keys have to be a string.
* `slen(key)` - returns the length of the string value if the key exists; returns `-1` otherwise.
* `append(key, data)` - Append the data (String) to an existing string value; returns *`False`* if it fails.
* `append(key, data)` - Append the data (String) to an existing string value; returns `False` if it fails.

<span id="lists"></span>
### Lists :
Expand Down Expand Up @@ -342,8 +346,8 @@ $ python -m unittest -v
<span id="releases"></span>
### Releases :
* Latest - `v0.2.0`
* Previous - `v0.1.3`
* Latest - `v0.2.1`
* Previous - `v0.2.0`
Donwload the latest release from [here](https://github.com/saurabh0719/elara/releases/).
Expand Down
49 changes: 24 additions & 25 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Elara :
-------

- Elara DB is an easy to use, key-value database written for python that can also be used as a fast in-memory cache. Includes various methods to manipulate data structures in-memory, secure database files and export data.
- Elara DB is an easy to use, lightweight NoSQL database written for python that can also be used as a fast in-memory cache. Includes various methods to manipulate data structures in-memory, secure database files and export data.

.. code:: sh
Expand Down Expand Up @@ -77,17 +77,17 @@ can transact data from an encrypted file.
contents of the encrypted database (using the key file) into the
program memory or generates a new key file and/or database file if
they don't exist in the given path and it encrypts/decrypts the
database file. Data is encoded into a *base64* format and then
encrypted using *Fernet encryption*
database file. Data is encoded into a ``base64`` format and then
encrypted using ``Fernet encryption``

Using ``exe_secure()`` without a key file or without the correct key
file corresponding to the database will result in errors. Key files and
DB files can be included inside the *.gitignore* to ensure they're not
DB files can be included inside the ``.gitignore`` to ensure they're not
pushed into an upstream repository.

- *``commit``* - this argument defaults to *``False``* ie. you will
- ``commit`` - this argument defaults to ``False`` ie. you will
have to manually call the ``commit()`` method to write the in-memory
changes into the database. If set to *``True``*, changes will be
changes into the database. If set to ``True``, changes will be
written into the file after every operation.

.. code:: python
Expand Down Expand Up @@ -126,21 +126,21 @@ file. Set the ``commit`` argument to ``True`` else manually use the
``commit()`` method to sync in-memory data with the database file.

- ``get(key)`` - returns the corresponding value from the db or
*``None``*
- ``set(key, value)`` - returns *``True``* or an Exception. The ``key``
``None``
- ``set(key, value)`` - returns ``True`` or an Exception. The ``key``
has to be a String.
- ``rem(key)`` - deletes the key-value pair if it exists.
- ``clear()`` - clears the database data currently stored in-memory.
- ``exists(key)`` - returns *``True``* if the key exists.
- ``exists(key)`` - returns ``True`` if the key exists.
- ``commit()`` - write in-memory changes into the database file.
- ``getset(key, value)`` - Sets the new value and returns the old value
for that key or returns *``False``*.
for that key or returns ``False``.
- ``getkeys()`` - returns the list of keys in the database with. The
list is ordered with the *``least recently accessed``* keys starting
list is ordered with the ``least recently accessed`` keys starting
from index 0.
- ``numkeys()`` - returns the number of keys in the database.
- ``retkey()`` - returns the Key used to encrypt/decrypt the db file;
returns *``None``* if the file is unprotected.
returns ``None`` if the file is unprotected.
- ``retmem()`` - returns all the in-memory db contents.
- ``retdb()`` - returns all the db file contents.

Expand All @@ -164,20 +164,20 @@ file. Set the ``commit`` argument to ``True`` else manually use the
# {'num1': 20}
Note - ``retmem()`` and ``retdb()`` will return the same value if
*``commit``* is set to *``True``* or if the ``commit()`` method is used
``commit`` is set to ``True`` or if the ``commit()`` method is used
before calling ``retdb()``

Cache:
~~~~~~

Elara can also be used as a fast in-memory cache. Start/open a new
instance and ensure the ``commit`` argument is *``False``* or left empty
instance and ensure the ``commit`` argument is ``False`` or left empty
(``commit`` defaults to ``False``), to prevent writes into the database
file.

- ``cull(percentage)`` - ``percentage`` (0 <= percentage <= 100)
defines the percentage of Key-Value pairs to be deleted, with the
*Least recently accessed* keys being deleted first. Elara maintains a
``Least recently accessed`` keys being deleted first. Elara maintains a
simple LRU list to track key access.

.. code:: python
Expand Down Expand Up @@ -222,14 +222,14 @@ Strings :
and calls the ``set(key, value)`` method for each pair. Keys have to
be a String.
- ``setnx(key, value)`` - Sets the key-value if the key does not exist
and returns *``True``*; returns *``False``* otherwise.
and returns ``True``; returns ``False`` otherwise.
- ``msetnx(dict)`` - takes a dictionary of key-value pairs as an
argument and calls the ``setnx(key, value)`` method for each pair.
Keys have to be a string.
- ``slen(key)`` - returns the length of the string value if the key
exists; returns ``-1`` otherwise.
- ``append(key, data)`` - Append the data (String) to an existing
string value; returns *``False``* if it fails.
string value; returns ``False`` if it fails.

Lists :
~~~~~~~
Expand Down Expand Up @@ -290,15 +290,15 @@ Hashtable/Dictionary :
- ``hnew(key)`` - Initialises an empty dictionary for the given key and
returns ``True`` or an Exception; key has to be a string.
- ``hadd(key, dict_key, value)`` - Assigns a value to a dictionary key
and returns *``True``*; returns *``False``* if the dictionary doesn't
and returns ``True``; returns ``False`` if the dictionary doesn't
exist.
- ``haddt(key, tuple)`` - Add a new key-value tuple into the
dictionary. Returns *``True``* if the dictionary exists; returns
*``False``* otherwise.
dictionary. Returns ``True`` if the dictionary exists; returns
``False`` otherwise.
- ``hget(key, dict_key)`` - Returns the value from the dictionary;
returns *``False``* if the dictionary doesn't exist.
returns ``False`` if the dictionary doesn't exist.
- ``hpop(key, dict_key)`` - Deletes the given key-value pair from the
dictionary and returns the deleted value; returns *``False``* if the
dictionary and returns the deleted value; returns ``False`` if the
dictionary doesn't exist.
- ``hkeys(key)`` - returns all the Keys present in the dictionary.
- ``hvals(key)`` - returns all the values present in the dictionary.
Expand Down Expand Up @@ -409,8 +409,8 @@ the ``test`` folder:
Releases :
~~~~~~~~~~

- Latest - ``v0.2.0``
- Previous - ``v0.1.3``
- Latest - ``v0.2.1``
- Previous - ``v0.2.0``

Donwload the latest release from
`here <https://github.com/saurabh0719/elara/releases/>`__.
Expand All @@ -420,5 +420,4 @@ Contributors :
~~~~~~~~~~~~~~

| Author - Saurabh Pujari
|
| Logo design - Jonah Eapen
14 changes: 9 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
setup(
name = 'elara',
packages = ['elara'],
version = '0.2.0',
version = '0.2.1',
license='three-clause BSD',
description = 'Elara DB is an easy to use, key-value database written for python that can also be used as a fast in-memory cache. Includes various methods to manipulate data structures in-memory, secure database files and export data.',
description = 'Elara DB is an easy to use, lightweight NoSQL database written for python that can also be used as a fast in-memory cache. Includes various methods to manipulate data structures in-memory, secure database files and export data.',
long_description = long_description,
author = 'Saurabh Pujari',
author_email = '[email protected]',
Expand All @@ -19,9 +19,13 @@
'storage',
'file storage',
'json storage',
'json database'
'key-value database'
], # Keywords that define your package best
'json database',
'key-value database' ,
'nosql',
'nosql database'
'cache',
'file cache'
],
install_requires=[
'cryptography'
],
Expand Down

0 comments on commit 81a3b49

Please sign in to comment.