“Machine Utilization Example” - Push data to MSSQL Database

In this file, data is pushed to an MSSQL database.

Download: utilization-push-sql.yml

 1description: >
 2    Sample MSSQL service commissioning file
 3
 4metadata:
 5  name: MSSQL push service
 6  icon: https://www.cybus.io/wp-content/uploads/2017/10/for-whom1.svg
 7  provider: cybus
 8  homepage: https://www.cybus.io
 9  version: 1.0.0
10
11parameters:
12  mssqlHost:
13    type: string
14    default: 172.17.0.1
15
16  mssqlPort:
17    type: integer
18    default: 1433
19
20  mssqlUser:
21    type: string
22    default: sa
23
24  mssqlPassword:
25    type: string
26    default: SomeLongSecurePassw0rd
27
28  mssqlDatabase:
29    type: string
30    default: tempdb
31
32resources:
33
34  mssqlDB:
35    type: Cybus::Container
36    properties:
37      image: mcr.microsoft.com/mssql/server
38      ports:
39        - 1433:1433/tcp
40      environment:
41        SA_PASSWORD: 'SomeLongSecurePassw0rd'
42        ACCEPT_EULA: 'Y'
43
44  mssqlConnection:
45    type: Cybus::Connection
46    properties:
47      protocol: Mssql
48      connection:
49        host: !ref mssqlHost
50        port: !ref mssqlPort
51        username: !ref mssqlUser
52        password: !ref mssqlPassword
53        database: !ref mssqlDatabase
54
55  mssqlQuery2:
56    type: Cybus::Endpoint
57    properties:
58      protocol: Mssql
59      connection: !ref mssqlConnection
60      write:
61        # Here we use the placeholder @someValue. The protocol driver will insert
62        # the value from the input JSON message under the key someValue
63        query: 'INSERT INTO machine (powerlevel, state, timestamp) VALUES (@powerlevel, @state, @timestamp)'
64
65  mapping:
66    type: Cybus::Mapping
67    properties:
68      mappings:
69        - subscribe:
70            topic: 'machine-state'
71          publish:
72            endpoint: !ref mssqlQuery2