Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access default hyperledger fabric-ca database

I have hyperledger fabric "First Network" up and running in Vagrant on Window 7. I would like to query on following tables of fabric ca database:

  • Affiliations
  • Users
  • Certificates

Kindly help me how and where I can find fabric ca database,

Thank You.

like image 769
deepak parmar Avatar asked Sep 06 '25 03:09

deepak parmar


2 Answers

If you are using version 1.1, you can use the fabric-ca-client affiliation list and fabric-ca-client identity list commands to see the affiliations and users table, respectively. The ability to list the certificates will be in a future version of the fabric-ca-client.

By default, the fabric-ca-server uses SQLITE and the name of the database file is fabric-ca-server.db in the home directory of the fabric-ca-server. You can use the sqlite3 fabric-ca-server.db command to enter a sqlite shell, and then issue select * from users to list the users table for example.

like image 59
Keith Smith Avatar answered Sep 07 '25 20:09

Keith Smith


You need to login to the docker container to run sqlite3 fabric-ca-server.db. Follow these steps:

$ docker ps

find your Fabric-ca container name from the response. Then issue this command:

 $ sudo docker exec -it <your-ca>  /bin/bash 

After logging in, change directories:

 root@c6cc601b0360:/# cd ca 
 root@c6cc601b0360:/ca#

Then connect to the database:

root@c6cc601b0360:/ca# sqlite3 fabric-ca-server.db 

Run a test query:

root@c6cc601b0360:/ca# select * from users
like image 34
chandrakanth Mamillapalli Avatar answered Sep 07 '25 21:09

chandrakanth Mamillapalli