Skip to main content

Saving

If a PYNDatabase object is initialized with a dictionary, it will update the original dictionary object as changes are made. Otherwise, you must call PYNDatabase.save() (unless autosave is set to True). The save method also has a file flag, which allows for easily saving to another file. The file type can be changed by setting the filetype parameter of the main class (see Pickling).

Command usage:

PYNDatabase.save()

Examples:

Basic usage:

from pyndb import PYNDatabase
db = PYNDatabse('filename.pyndb')
db.set('hello', 'world')
db.save() # <--

Saving an existing dictionary to file using the file flag

from pyndb import PYNDatabase
dictionary_obj = {'hello': 'world'}
db = PYNDatabse(dictionary_obj)
db.set('hello', 'world')
db.save(file='filename.pyndb') # <--