saurabh0719 / elara

Elara DB is an easy to use, lightweight persistent key-value store that can also be used as a fast in-memory cache. Manipulate data structures in-memory, encrypt database files and export data. :dart:

Home Page:https://pypi.org/project/elara/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Keyfile Path only in root directory

schmurian opened this issue · comments

Hi,

I've tried to create a new database in secure mode and wanted to move both files into a subdirectory
db = elara.exe_secure("path/new.db", "path/newdb.key")
While the db file was created in the subdirectory, the keyfile wasn't accepted as argument which resulted in 'edb.key' being created in the root directory.

It would be great if this could be fixed. (If this is on purpose, please share the reasons for this decision. Curious!)

Thank you for this great app!

Hi @schmurian

Thank you for pointing this out! This is indeed an issue, as the arguments can't be skipped, and hence this is a mistake in the Elara documentation!

I'd suggest trying something like this :

import elara

db = elara.exe_secure(path="path/new.db",  key_path="path/edb.key")  

db.set("num", 20)
print(db.get("num"))

This should solve the issue for you. By default commitdb is False. If you would like to change that you can do the following :

option-1

db = elara.exe_secure(path="path/new.db",  commitdb=True, key_path="path/edb.key") 

OR

option-2

db = elara.exe_secure("path/new.db", True, "path/edb.key") 

I intend to extend Elara further and add more extensions/arguments hence I suggest you go with option-1 over option-2 if you're maintaining any long term code base, so as to stay unaffected by any future updates.

Hope this helps :). I will update the documentation with the same very soon. Thanks again for pointing this out!

Ah, yes! Thank you! That does the trick.
Great, looking forward to upcoming updates!

Cheers!