Basics

About

This documentation covers version 3.4.3

What is pyndb?

pyndb, short for Python Node Database, is a package which makes it easy to save data to a file while also providing syntactic convenience. It utilizes a Node structure which allows for easily retrieving nested objects. All data is wrapped inside of a custom Node object, and stored to file as nested dictionaries. It provides additional capabilities such as autosave, saving an existing dictionary to file, creating a file if none exists, and more. The original program was developed with the sole purpose of saving dictionaries to files, and was not released to the public.

Why was it created?

pyndb was created when jvadair (the author) attempted to learn how to use sqlite with python. He decided that writing commands into strings and then passing them into a command execution function was too annoying. Thus DataManager was born. It was used on internal projects, until jvadair decided that that it too was quite annoying to use, due to it working poorly with nested dictionaries. Conceptualized on a sticky note late at night, he realized that he could recursively spawn objects within a master class. This solved the aforementioned issue, and so DataManager was rewritten into pyndb.

Installation

It's easy

To install, you can either install via pip:
pip install pyndb
Or, you can download the package folder and run:
python -m pip install dist/*.whl

Structure

How values are represented

All keys in a dictionary (loaded from file/object) managed by a PYNDatabase object will be represented as Node objects. Each Node object scans the dictionary it represents, and creates new Nodes for each key. This process repeats recursively. A Node object can also represent any other class, but you must then use the transform method - or replace the value with a dictionary - in order to create a subnode.