Skip to main content

Easily interact with JSON-based encrypted databases.

Project description

securedb

Downloads PyPi version PyPI status

securedb is a lightweight Python database framework to handle basic key-value encrypted data.

pip install securedb --upgrade

Content index

Changelog

New in 2.0.3 (Latest)

  • Switched to hatch for packaging

New in 2.0.2

  • Bugfix in the get_many() function
  • Pep8 compliant
  • Fixes in the docs

New in 2.0.1

  • Fixed docs missing initialization instructions

New in 2.0.0

  • Completely redesigned db schema, now using single files for each database key
  • Maximum database storage size heavily increased
  • Lower memory consumption
  • Mapped every possible error
  • Custom key file path

New in 1.1.0

  • force kwarg added in the initialization; see initialization
  • You don't need to manually encode the key during the initialization
  • If there is no error, all the functions now return True
  • Useless print() functions were removed
  • Smoother error handling

Documentation

DB Creation

Key

To create a database, an encryption key is needed. To generate it, you can use the built-in newkey() function.

import securedb
securedb.newkey(keyfile="path/to/key/storage") # the "keyfile" kwarg is optional and default set to ".key".

This will create a new file: it'll be named ".key" if no keyfile is specified, else it'll be named as you want. The key file is the file which contains the encryption key.

Initialization

import securedb

db = securedb.Db(db_path, path_to_key, force=True)
# path is the database storage location, key is the path to the key file and force is described below.

With force=True the program will create a new db in the given path if no database is found. force is optional and default set to False. Remember that if you lost your key there will be no way to recover the database content.

Writing keys

write()

The write(key, value) function allows you to insert a single value into the database. key is the value name value is the value data.

key is used to access the data, and must be an integer or a string; value can be anything such as boolean, integer, string, array, list, dictionary ecc.

write_many()

The write_many(payload) function allows you to write many values in a single time. payload is a dictionary with all the values you need to insert: {key: value, key1: value1, key2: value2} etc. There isn't any limit regarding the size of the payload. For perfomance reasons, we suggest you to use payloads with a maximum size of 5mb, even if there is no software limit.

Deleting

delete()

The delete(key) function allows you to delete a single value from the database. key is the value's key inside the database (see write) and must be a string or an integer.

delete_many()

The delete_many(payload) function allows you to delete many values at the same time. payload is a list of the keys you want to delete: [key, key1, key2] etc.

clear()

The clear() functions is a dangerous function that allows you to erease the whole database. Be careful using it, because this action cannot be undone and the function doesn't ask confirmation before ereasing the database.

Reading

get()

To read any value from the database, you need to use the get(key) function. key is the key of the value you want to read (see write).

get_many()

To read any value from the database, you need to use the get_many(keys) function. keys is a list of the keys you want to read (see write).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

securedb-2.0.3.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

securedb-2.0.3-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file securedb-2.0.3.tar.gz.

File metadata

  • Download URL: securedb-2.0.3.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for securedb-2.0.3.tar.gz
Algorithm Hash digest
SHA256 5fe5fda1b4418d8ea00fbb5bf9d61acb83fd3dcd3d41f674a24eaba9889f058f
MD5 5458da1be4377ef90e3002affe18d709
BLAKE2b-256 c28bb9dcaf9f129a735010e00e88bd563aadc336d09fff3c65ff2224e08acbb5

See more details on using hashes here.

File details

Details for the file securedb-2.0.3-py3-none-any.whl.

File metadata

  • Download URL: securedb-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for securedb-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1c573e8fa31035e753c893bff70ae0fa8ad91069a91dfa349a0da3fdab81de82
MD5 5bb86fea00b76ce970b2608a73b90dea
BLAKE2b-256 fdc68db1da3bf6ceedbba24cd63eafce9241c378e3b91f7f8ec35d7efcc652e9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page