Skip to main content
Advanced Search
Search Terms
Content Type

Exact Matches
Tag Searches
Date Options
Updated after
Updated before
Created after
Created before

Search Results

51 total results found

Reloading/retrieving the data from the file

pyntree Supported file types and actions

To reload the data from the file, use the following method: File.reload() This method is only 1 line of code: self.data = self.read_data() The read_data method returns the data stored in the file, after being parsed into a python dictionary.

Moving beyond a single flat file

pyntree Tips, Tricks, and Tidbits

For more complex projects, a flat-file database may not be the way to go. Here is one example of how you could store data in a more distributed way: db folder users user1.pyn user2.pyn etc transactions 001.pyn 002.pyn etc config.json ...

How to fix pyntree installing as UNKNOWN-0.0.0

pyntree Tips, Tricks, and Tidbits

pip install --upgrade pip wheel setuptools

Installing

pyntree Getting started

pyntree is available via pip: pip install pyntree That's it!

Encrypting a file

pyntree Supported file types and actions

Encryption is a new feature as of 1.0.0! To use encryption, first type pip install pyntree[encryption] to install the necessary dependencies. To encrypt your data, simply specify a password parameter for the Node when saving or loading. db = Node('encrypted...

Getting the name of a Node

pyntree Basic Usage

Syntax: Node._name Let's say you have a miscellaneous Node that got passed to a function somehow. What is its purpose? The name of the Node may shed some light on this: from pyntree import Node x = Node('test.pyn') x._name # 'test.pyn' x.a = 1 x.a._n...

The where() method

pyntree Additional Features

Syntax: Node.where(**kwargs) Let's say you have a lot of users, sorted by IDs. Now, you want to find a user with a specific, unique email. Sounds like a pain, right? Nope. Here's how to do it with pyntree: db = Node("users.pyn") my_user = db.where(email=...

Converting back to a dictionary

pyntree Additional Features

Syntax: dict(Node) This is pretty straightforward, as shown above. The command will make a new dictionary. If you want to directly manipulate a Node's data instead, you can simply perform methods on the called function, as shown in the section Math and obj...

Node representation

pyntree Additional Features

Syntax: str(Node) # or repr(Node) str(Node) will return a string representation of the data stored within the Node repr(Node) will return the same as str(Node), but wrapped within the text "Node()"

Math and object manipulation

pyntree Basic Usage

Syntax: Node += val Math operations If you used pyndb, you probably had to do something like this: x = PYNDatabase({}) x.set("a", 1) x.set("a", x.a.val + 1) Let's be real here, this SUCKS. pyntree does it better: x = Node() x.a = 1 x.a += 1 Wow, t...

Getting the children

pyntree Basic Usage

Syntax: Node._children The ._children property returns a list of Node objects (the children of the parent Node)