Skip to main content

dictature -- A generic wrapper around dict-like interface with mulitple backends

Project description

Dictature

A wrapper for Python's dictionary with multiple backends.

Installation

pip install dictature

Dictature usage

This package also includes a class that allows you to use your SQLite db or any backend as a Python dictionary:

from dictature import Dictature
from dictature.backend import DictatureBackendDirectory, DictatureBackendSQLite

# will use/create the db directory
# dictionary = Dictature(DictatureBackendDirectory('test_data'))
# will use/create the db file
dictionary = Dictature(DictatureBackendSQLite('test_data.sqlite3'))

# will create a table db_test and there a row called foo with value bar
dictionary['test']['foo'] = 'bar'

# also support anything that can be jsonized
dictionary['test']['list'] = ['1', 2, True]
print(dictionary['test']['list'])  # prints ['1', 2, True]

# or anything, really (that can be serialized with pickle)
from threading import Thread
dictionary['test']['thread'] = Thread
print(dictionary['test']['thread'])  # prints <class 'threading.Thread'>

# and deleting
del dictionary['test']['list']  # deletes the record
del dictionary['test']  # drops whole table

Currently, the following backends are supported:

  • DictatureBackendDirectory: stores the data in a directory as json files
  • DictatureBackendSQLite: stores the data in a SQLite database
  • DictatureBackendMISP: stores the data in a MISP instance
  • DictatureBackendWebdav: stores data in a WebDav share as files

Transformers

You can also use transformers to change how the values are stored. E.g. to encrypt data, you can use the AESTransformer (which requires the pycryptodome package):

from dictature import Dictature
from dictature.backend import DictatureBackendDirectory
from dictature.transformer.aes import AESTransformer

name_transformer = AESTransformer('password1', True)
value_transformer = AESTransformer('password2', False)

dictionary = Dictature(
    DictatureBackendSQLite('test_data.sqlite3'),
    name_transformer=name_transformer,
    value_transformer=value_transformer
)

Currently, the following transformers are supported:

  • AESTransformer: encrypts/decrypts the data using AES
  • HmacTransformer: signs the data using HMAC or performs hash integrity checks
  • GzipTransformer: compresses given data
  • PassthroughTransformer: does nothing
  • PipelineTransformer: chains multiple transformers

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

dictature-0.10.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

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

dictature-0.10.0-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file dictature-0.10.0.tar.gz.

File metadata

  • Download URL: dictature-0.10.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dictature-0.10.0.tar.gz
Algorithm Hash digest
SHA256 9c629fc9076bc0a307e993945f4c89e351c2ac2f416800850a34f54492aadd8c
MD5 12b1daf28ac32d50fba127ce33206142
BLAKE2b-256 1a9d0df3b8f83e70c5f2a24e68d980ac574c122236c2560afa270e423df3204f

See more details on using hashes here.

Provenance

The following attestation bundles were made for dictature-0.10.0.tar.gz:

Publisher: pypi-deploy.yml on esoadamo/dictature

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dictature-0.10.0-py3-none-any.whl.

File metadata

  • Download URL: dictature-0.10.0-py3-none-any.whl
  • Upload date:
  • Size: 16.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dictature-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b036388005194a089df66932018dc4fac3f5f18f7366652046e96e30a7d88b1c
MD5 3a34542d5a899d000c871e3c723740f0
BLAKE2b-256 e5d646c227b7bef4555c0f10208d0c9d3e442380a742b4ab7fd14de1537ad059

See more details on using hashes here.

Provenance

The following attestation bundles were made for dictature-0.10.0-py3-none-any.whl:

Publisher: pypi-deploy.yml on esoadamo/dictature

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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