How to exchange data between blockchain and database

+5 votes
I am working on a project wherein there are multiple systems that process the data and finally put it in a  Azure SQL database. I have currently a blockchain with two nodes that is supposed to exchange (pull and push) data to this database in real time.  Any ideas how this can be implemented adhering the best practices of using Multichain?
asked Mar 12, 2018 by anonymous

1 Answer

+1 vote

For pulling the data from the blockchain to the database, you can use the walletnotify setting to have a script triggered every time a new transaction occurs which is of interest to the node. Or you can poll the node and pull out information one block at a time using getblock with verbose set to 4.

As for pushing the data directly from the database to the blockchain, we would not recommend this. Instead, write the new data to the blockchain directly, and then let it be pulled into the database (or into multiple databases) using the mechanism in the above paragraph.

answered Mar 12, 2018 by MultiChain
Thanks. I agree with you however as I mentioned, there are multiple systems in place already that push data to the database. Hence I cannot write new data to blockchain directly.  The creation of block needs to be triggered from the database. Any idea how to tackle this situation? It is a good idea to write a database trigger to create a new block in a blockchain?
Yes, you will need to build some kind of trigger that watches for database changes, and then makes an appropriate blockchain transaction. The exact details of this will depend on the database that you are using.