Dinemic has released Python wrapper for libdinemic. Now you can use robustness of this tool directly in Python3.


Official documentation for pydinemic and instructions for stable version could be found here


First, get latest version of libdinemic from packages.dinemic.io:

wget https://packages.dinemic.io/nightly/ubuntu-18.04/current/libdinemic_19.07.72903994_amd64.deb
sudo dpkg -i libdinemic_19.07.72903994_amd64.deb

then install Boost::Python dependency:

sudo apt install python3-dev libboost-python-dev

and finally install pydinemic:

sudo pip3 install pydinemic

First steps

Now, when we got pydinemic installed, we can write some code in Python. Let’s start with database model:

import pydinemic

# Let's start Dinemic agent

class MyModel(pydinemic.DModel):
    name = pydinemic.DField('Name', False)
    # Encrypted field keeping our salary
    salary = pydinemic.DField('Salary', True)

my_model = MyModel('MyModel', [])

Above code will create new instance of MyModel class, without any additional authorized keys. We can recreate this object anywhere, from owned ID:

my_existing_model = MyModel('MyModel:qj203fr...', '')
my_existing_model.name = 'Bob'

Above code will create local instance of MyModel class, but it won’t be able to create signed changes until we have valid cryptographic keys from machine, where it was created


Another feature of pydinemic is to use listeners mechanism known from C++ Dinemic framework. To monitor changes in your model or any part of database, just inherit Listener class:

import pydinemic

class Listener(pydinemic.DAction):
    create = False
    created = False
    update = False
    updated = False
    def on_create(self, object_id, key):
        # Do something when object is going to be created

    def on_created(self, object_id, key):
        # Do something when object was created
    def on_update(self, object_id, key, old_value, new_value):
        print('Hey! I'm going to change to: ' + new_value)

and then we could assign this listener to our data model:

listener = Listener()


The pydinemic module is still under development. It should gain some more features known from C++ Dinemic framework soon, like authorized keys support, better filtering of signed/unsigned updates on models and so on.

Keep checking our website to be up to date