---
updatedAt: 2025-11-05T20:12:04.000Z
agentTools:
  projectIndex: https://esf.eurotech.com/v5.1.0/llms.txt
---

# DB Store and Filter

This tutorial will present how to use DB Store and DB Filter components in Wires using the OPC-UA simulated server already used in [OPC-UA Application](https://esf.eurotech.com/v5.1.0/docs/opcua-application-in-kura-wires).

The DB Store component allows the wire graphs to interact with the database provided by ESF. It stores in a user-defined table all the envelopes received by the component. The component can be configured as follows:

* **table.name**: the name of the table to be created.
* **maximum.table.size**: the size of the table.
* **cleanup.records.keep**: the number of records in the table to keep while performing a cleanup operation.

The DB Filter component, instead, can run a custom SQL query on the ESF database. It can be configured as follows:

* **sql.view**: SQL to be executed to build a view.
* **cache.expiration.interval**: cache validity in seconds. When the cache expires, a new read in the database will be performed.

The following procedure will create a wire graph that collects data from a simulated OPC-UA Server, stores it in a table in the database, using the DB Store component, and publishes it in the cloud platform. Moreover, the DB Filter is used to read from the database and write data to the OPC-UA Server based on the values read.

# Configure OPC-UA server simulator

1. Download the <a href="https://s3.amazonaws.com/kura-resources/opcua_demo_server.dp" about="_blank">OPC-UA server simulator</a> bundle and install it on your ESF instance. It will create a simulated OPC-UA server that exposes some sensors (light, temperature and water sensor) and some actuators (buzzer, led and fan).
2. In the ESF Administrative Web Interface, select “OPCUA Server demo” in “Services” and set **server.port** to 1234. Click the **Apply** button. This will start an OPC-UA​ server on port 1234.

# Configure Wires OPC-UA application

1. Install the OPC-UA Driver from <a href="https://marketplace.eclipse.org/content/opc-ua-driver" about="_blank">Eclipse Kura Marketplace</a>
2. Use the local ESF Administrative Web Interface to create a new OPC-UA driver instance:
   * Select **Drivers and Assets**, click the **New Driver** button
   * Select **org.eclipse.kura.driver.opcua**, type in a name, and click **Apply**: a new service will show up under Services.
3. Configure the new service as follows:
   * **endpoint.ip**: localhost
   * **endpoint.port**: 1234
   * **server.name**: leave blank

![2378](https://files.readme.io/1c26722-OPCUADriverConfig.png "OPCUADriverConfig.png")

4. Click on **Wires** under **System**
5. Add a new **Timer** component and configure the interval at which the OPC-UA server will be sampled
6. Add a new **Asset** with the previously added OPC-UA Driver
7. Configure the new OPC-UA asset, adding new Channels as shown in the following image. Make sure that all the channels are set to READ.

![2362](https://files.readme.io/84d6718-OPCUADriverConfig1.png "OPCUADriverConfig1.png")

8. Add a new **DBStore** component and configure it as follows:
   * **table.name**: WR\_data
   * **maximum.table.size**: 10000
   * **cleanup.records.keep**: 0
9. Add a new **Publisher** component and configure the chosen cloud platform stack in **cloud.service.pid** option
10. Add **Logger** component
11. Add another instance of **Timer**
12. Add a new **DBFilter** component and configure it as follows. The query will get the values from the light sensor and if they are less than 200, the fan is activated.
    * **sql.view**: SELECT (CASE WHEN “light” < 200 THEN 1 ELSE 0 END) AS “led” FROM “WR\_data” ORDER BY TIMESTAMP DESC LIMIT 1;
    * **cache.expiration.interval**: 0
13. Add another **Asset** with the OPC-UA Driver, configured as shown in the following image. Be sure that all the channels are set to WRITE.

![2374](https://files.readme.io/9819dac-OPCUADriverConfig2.png "OPCUADriverConfig2.png")

14. Connect the components as shown in the following image, then click on “Apply” and check the logs and the cloud platform that the data is correctly published.

![2378](https://files.readme.io/9c60b4c-OPCUAWiresDB.png "OPCUAWiresDB.png")