Modbus to SQL database
A historian does not have to be a product. The Gateway polls the registers, turns them into engineering values with a name, a unit and a quality, and inserts one row per value into a table it creates when it is missing: ts, device, tag, value, text_value, quality, unit, indexed by device, tag and time.
Typical use case
A plant already runs PostgreSQL or SQL Server for its own applications and wants machine data beside it, queryable with the tools it has, without a second platform. SQLite on the gateway itself covers a standalone site that only needs a local record.
ts | device | tag | value | quality | unit
2026-09-29 07:25:03.629+05:30 | Main meter | Voltage_L1 | 230.5 | GOOD | VConfiguration approach
Choose the database
SQLite writes a file in the gateway's data directory and needs nothing else. PostgreSQL, MySQL / MariaDB and SQL Server take host, port, database, user name and an encryption setting; the password is set on the device, never in the design.
Decide the row rate
A rate limit on the wire gives one row per tag per interval; a deadband gives a row only when the value moved. Energy totals rarely need a row a second.
Batch the inserts
Rows per transaction and a batch wait keep the database's write load sensible; Delete rows older than keeps the table bounded.
Survive an outage
Store & Forward buffers rows on disk while the database is unreachable and inserts them in order when it returns.
Questions engineers ask
Does the gateway need a schema?
No. It creates the table when it is missing, with the columns above and an index on device, tag and time. Use your own table name if you prefer.
Can one design write to a database and a broker?
Yes. The device is polled once and the values are routed to each destination, each with its own deadband or rate limit.
Build a Modbus to SQL database gateway
Create a project, define the device and its tags in the Edge Logic Editor, and download a runtime to test at the plant.