Reputation: 20372
I understand Hyperledger Fabric stores the data in a Level or Couch DB. How can one access this db from outside the chaincode? What are the details? Is there a working example or tutorial somewhere?
E.g., suppose someone is developing a traditional web based application in which MySQL is used as the data store. Typically all read/writes happen through the application code but administrators and data scientists can also access the MySQL db through the MySQL command line for ad-hoc queries. In the same way if someone wants to access the level or couch db associated with Fabric, how to do it?
Upvotes: 1
Views: 1768
Reputation: 5570
With regard to your Data Scientists accessing the CouchDB State Database, please see this paragraph extracted from the Fabric Docs
"The blockchain data structure is optimized to validate and confirm transactions, and is not suited for data analytics or reporting. If you want to build a dashboard as part of your application or analyze the data from your network, the best practice is to query an off chain database that replicates the data from your peers."
Running data analysis against the State Database may not give good performance and a good experience, but it may also degrade the performance of your applications transacting with the Fabric.
You can use Event Listeners to populate and update an off-chain database dedicated to analysis and reporting.
Upvotes: 4
Reputation: 11
CouchDB provides REST based api. You can interact with CouchDB using cURL from terminal or using a browser. More on this is here: http://docs.couchdb.org/en/stable/intro/tour.html#
LevelDB does not provide a server or command-line interface. To be able to view data you can use third party viewer. Filepath for leveldb is /var/hyperledger/production in peer container.
Upvotes: 1