All Products
Document Center


Last Updated: Apr 03, 2020

To export the blockchain data to relational database, you can configure the mapping between the blockchain data and the table in database. After the mapping is configured, Alibaba Cloud Blockchain as a Service (BaaS) automatically exports specific data to target table. You can use SQL statements and other database tools to process the data further.

Configure Database trigger

Note: Before you configure a Database trigger, you must install the cloud service integration module.

  1. Find the target organization in the My Organizations section and click Cloud service integration on the right side.
  2. Click the Database tab, and then click Add configuration.
  3. In the Add Database configuration side pane that appears, set the following parameters:

    • Name: the name of the trigger for easy identification.
    • Channel/network: the fabric channel chosen by the trigger to export data.
    • smart contract: The smart contract corresponding the exported data. It will be one screening condition in below default filter expression.
    • Event type: the type of events corresponding the exported data. Fabric only supports Tx here.
    • Database Type: the type of target database.
    • Data source: the address of database instance, which should be accessed via public network.
    • User name: the database user name which has the update privilege of the target table.
    • Password: the corresponding password.
    • Database: the target database name.
    • Table name: the target table name.
    • Failure threshold: Advanced option. After the number of failure exceeds this value, the trigger enters the failed state and stops processing. -1 means the number of failure is unlimited, and the trigger will not enter the failed state.
    • Filter: Advanced option. In this expression, you need to implement the data filter and mapping to table columns. The trigger provides a default expression, which can extract the valid transactions generated by specific smart contrant, and then export the transaction ID, create time, key-value and other data. For more information, see Use Filter.Add configuration
  4. Click Add. After the trigger is added, it appears in the list.create complete


    1. After the trigger is created, it will export data from the latest block.
    2. When a trigger exports data to an integrated database, a database processing error or parameter configuration error causes the trigger status to become Exception. You can move the pointer over Exception to view the error information.
    3. When the integrated database returns an exception, the trigger retries processing. If the retry fails multiple times, the trigger discards the data, which is counted as one failure. If the aggregate number of failure doesn’t exceed the failure threshold, the trigger exports subsequent data. If the aggregate number of failure exceeds the failure threshold, the trigger enters the failed state and stops processing. You can repair the trigger or relevant service and enable it again, the failure number will return to zero.
    4. Block height field indicates the latest block has been processed by the trigger, which reflects the progress of the trigger.
  5. After a trigger is created, you can perform the following operations:

    • Delete: deletes the trigger.
    • Disable: stops data export to the database.
    • Enable: exports data to the database you configured for the trigger. After the trigger is enabled, it exports data of the latest block. The data that are generated while the trigger is disabled are discarded.