Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Commit

Permalink
Add saveDataBase
Browse files Browse the repository at this point in the history
  • Loading branch information
Loong committed Jul 16, 2023
1 parent e1256b4 commit 73a9379
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions easyNoSQL/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,25 @@ def writeValue(keyName,valueName) -> bool:

def changeSalt(newSalt) -> None:
salt = newSalt

def saveDataBase(filename,password='') -> bool:
noPassword = False
if password == '':
noPassword = True
if noPassword:
try:
with open(filename + '.json', 'w') as f:
f.write(json.dumps(t))
except:
raise serror.KVDataBaseError(403,"An error occurred manipulating the database file.")
return True
d = json.dumps(t)
d = cryptos.encode(password + salt,d)
try:
with open(filename + '.json', 'w') as f:
f.write(d)
except:
raise serror.KVDataBaseError(403,"An error occurred manipulating the database file.")

def version():
print('easyNoSQL - KV Database, Version: ' + easyNoSQL.system.VERTEXT)
Expand Down

0 comments on commit 73a9379

Please sign in to comment.